Python Forum
import yaml error for python3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
import yaml error for python3
#1
Hi All,

#!/bin/python
import yaml
print('yaml')
Traceback (most recent call last):
File "test.py", line 2, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
Yes, pyyaml is not installed in the python3, however it is installed and available in the python (python2).

So, how to install and make it available to python3 as well?

Any suggestions would be much appreciated. Thank you.
Regards,
Maiya
Reply
#2
Type python3 -m pip install --user pyyaml in a terminal. Modules installed for one python are not visible from other pythons.
Reply
#3
Thanks a lot Sir.
Reply
#4
Hi Sir,

I have created a project using python (2) and wanted to migrate/support to python 3 now. So is there any best and efficient way to find out any code of the my project/product which is not supported to python 3.
My project contains (11k lines of code), I wanted to know this without executing any of the my unit test scenario.

Any helps regarding this would really helps and much appreciated. Thanks a lot
Regards,
Maiya
Reply
#5
The simplest way to convert python 2 code into python 3 is to use the 2to3 program. Here is a very clear tutorial video about how to use it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,166 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Understanding and debugging memory error crashes with python3.10.10 Arkaik 5 1,977 Apr-18-2023, 03:22 AM
Last Post: Larz60+
  import module error tantony 5 3,359 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Append data to Yaml section tbaror 0 6,890 Feb-09-2022, 06:56 PM
Last Post: tbaror
  Cryptic Error with import statement Led_Zeppelin 2 2,478 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,490 Jan-04-2022, 01:05 PM
Last Post: Anldra12
Thumbs Up Parsing a YAML file without changing the string content..?, Flask - solved. SpongeB0B 2 2,222 Aug-05-2021, 08:02 AM
Last Post: SpongeB0B
  import module with syntax error Skaperen 7 5,159 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Import Error Christian 3 3,130 Apr-17-2021, 11:27 PM
Last Post: bowlofred
  Folium import error kashif_flavio 2 3,568 Dec-07-2020, 08:58 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020