I am on Mac OS Sierra, with home-brew, pip and python3 installed. I Tried running a script that required the requests module, but I keep getting this error:
Traceback (most recent call last):
File "listing_seq.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Despite running:
sudo pip3 install requests
sudo pip install requests
sudo pip install requests --upgrade
Any suggestions?
Update:
When I try running using virtualenv I get:
Running virtualenv with interpreter /usr/local/bin/python3
ERROR: File already exists and is not a directory.
Please provide a different path or delete the file.
The most common error is having another file with the name of any of the libraries you requested in the same path.
The other possible error is if the python you are using to execute the file is not python 3 but rather the defalut python from your OSX. See the accepted answer on this for better understanding of a possible issue. Also share your code to identify the bug.
Related
I'm running arch and when I try to use aws in the terminal I get a python-like error:
Traceback (most recent call last):
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
ModuleNotFoundError: No module named 'awscli'
This happened for pip as well which I resolved by python -m ensurepip but I don't know why it was like that in the first place. I even tried explicitly adding the path to aws to my PATH to no avail.
Well, pip and other applications are in fact python programs. Apparently you just lack the 'awscli' module. A first try would be just install this module.
Try this command
sudo pip install awscli --force-reinstall --upgrade
these are the Error messages I am geeting on running any of my project modules.
Traceback (most recent call last):
File "C:\Users\hsnl\BlockchainCodesTutor\Wallet.py", line 3, in <module>
import Transactions
File "C:\Users\hsnl\BlockchainCodesTutor\Transactions.py", line 2, in <module>
import Signatures
File "C:\Users\hsnl\BlockchainCodesTutor\Signatures.py", line 2, in <module>
import cryptography
ModuleNotFoundError: No module named 'cryptography'
I have already installed the cryptography module and was working perfectly until today I start getting this message that " No module named 'cryptography'".
I have again installed the cryptography as well as pip package but still showing the same error.
There might be loose versions running on your system. Please try the following:
python -m pip uninstall cryptography
python -m pip install cryptography
You can also check out this with python -m to make sure you are not using a loose pip.
You might not have cryptogtaphy installed correctly. I see you are using windows. Open commandline as an administrator and run pip install cryptography again. Enshure that the installation finishes without any errors and consider to restart your python interpreter after installation.
For further help you should post more details like the output of pip and your code leading to the error, so a more detailed answer for your problem can be given.
Try download cryptography whl from here.
Then use pip install cryptography-XXX.whl
For example:
pip install cryptography-3.3.1-cp36-abi3-win_amd64.whl
And now just supports python2.7 and python3.6.
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
Such issues occur when there are multiple distribution of python installed in your system.
Just run: pip3 list command and see whether you are able to see the package in the list. If not, you are not installing the PyYaml package at the correct location.
PS: also sometimes for normal user python is at different location and for sudo user, it is at different location. Check running the command without giving sudo.
I tried to install redis-py lib via pip. It was installed successfully, but when I tried to import redis in python3 shell, I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'redis'
In python2 it gets imported with no errors.
I have tried all three pip, pip2, pip3 on my machine (ubuntu 17.10). Also I have python3.6 installed. I also tried easy_install
You are installing it in Python 2.7 (you have probably already know this). If python3.6 brings up the correct Python version on your system then this should work for you:
python3.6 -m pip install redis
If you are unsure what each pip version brings up you can use the which command to list the file path. This will give you a good indication as to where to look.
Also pip3.6 install redis might work but is not as secure as the above
I'm new to Linux and I'm trying to install packages through a Makefile so users can run my Python 3 program.
sudo pip install python3-weather-api
However, even after uninstalling a previously installed version, the package seems to be going to the 2.7 version of Python.
Requirement already satisfied: python3-weather-api in /usr/local/lib/python2.7/dist-packages
Then, when I run the program, it can't find the module (it works locally in Python 3 just fine).
SystemExit: 1
Traceback (most recent call last):
File "project.py", line 11, in <module>
from weather import Weather
ImportError: No module named 'weather'
Is there a way I can point the original installation so when I run python3 project.py it can find the module?
Thanks very much!
I would recommend you to use pyenv to manage your Python installations, but, for now, try to run:
sudo pip3 install python3-weather-api