I have a centos7 machine with python-2.7.5 installed as a default python.
For my work, I need 3.x version of python on the same machine, so I have installed python-3.6.8 and created a soft link where /usr/bin/python
point to /usr/bin/python3
with following command:
sudo ln -fs /usr/bin/python3 /usr/bin/python
Now, for a sample python script, let's say: test.py, I am getting ModuleNotFoundError: No module named 'yaml'
error when I am trying to import yaml
in it.
test.py script is as below:
#!/usr/bin/python3
"""
Sample python script to import yaml.
"""
import yaml
print("Hello! Could you please help me resolve this?")
And the error is as below:
[cloud-user@xx.xx.xx.xx]$python test.py
Traceback (most recent call last):
File "test.py", line 6, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
I saw a couple of queries raised on stackoverflow and on github, like this, this and this, but do not see any response that has resolved this issue.
As suggested on the links above, I have installed pyyaml using below command:
sudo python3 -m pip install pyyaml
and sudo pip3 install pyyaml
but I am still continue to get ModuleNotFoundError
error.
Could anyone please help me resolve this issue?
Thanks in advance,
Akshat Sharma