Python Forum
import yaml error for python3 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: import yaml error for python3 (/thread-28332.html)



import yaml error for python3 - maiya - Jul-14-2020

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


RE: import yaml error for python3 - Gribouillis - Jul-14-2020

Type python3 -m pip install --user pyyaml in a terminal. Modules installed for one python are not visible from other pythons.


RE: import yaml error for python3 - maiya - Jul-15-2020

Thanks a lot Sir.


RE: import yaml error for python3 - maiya - Jul-15-2020

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


RE: import yaml error for python3 - Gribouillis - Jul-15-2020

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.