ModuleNotFoundError: No module named 'requests' after pip install [duplicate] - python

This question already has answers here:
ModuleNotFoundError: No module named 'requests' but it's installed?
(2 answers)
Closed 1 year ago.
I know similar questions have been asked before but I couldn't find the solution to my problem.
I am getting the following error message after trying to import requests:
C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe C:/Users/Jm/PycharmProjects/Test/Test_001
Traceback (most recent call last):
File "C:/Users/Jm/PycharmProjects/Test/Test_001", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
I only have one version of python installed and python -m pip install requests is saying all the requirements are already satisfied.

Run this code:
C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe -m pip install requests
This forces the installation directory to your python install.
This gives a much different effect than simply python -m pip install requests

As #Daniel Scott mentioned before use the command mentioned above or below
$: path-to-your-python-command -m pip install name-of-module
If you are using linux/mac then you can find path-to-your-python command using:
$: which python3
/usr/bin/python3
Lets say your python is installed here /usr/bin/python3 and the module you are installing is requests. Then you can use:
$: /usr/bin/python3 -m pip install requests

Related

ModuleNotFoundError: No module named 'cryptography'

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 can't install Python libraries due to "from pip import main cannot import name main" [duplicate]

This question already has answers here:
Error after upgrading pip: cannot import name 'main'
(32 answers)
Closed 3 years ago.
I am not expert in Ubuntu, so i need your help that will make my day.
I have several versions of python on my machine because i'am working with odoo several odoo framewrok versions, after installing odoo 10 which works on Python 2.7. I am deleting it and i have this issue when reinstalling.
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
How can i resolve that issue?
NOTE
When i write type pip in terminal i get this location pip is /home/autoparts/.local/bin/pip. I thougt the pip location is not as the error above.
Any help will be appricated.
Check out this topic on Github Pip 5447
They offered two ways as mentioned below:
We solved this issue by clear hash in bash:
$ hash -d pip
Or in dash (sh):
$ hash -r pip
Or
In this case, the particular issue seems to be:
pip3 install --user --upgrade pip installs pip 10 in the user site, but doesn't uninstall the system site copy of pip.
User runs the system wrapper from /usr/bin/pip3 which is from the OS-supplied pip 8. This wrapper expects to see pip 8, but it doesn't because user site takes priority over system site.
The solution is to use the pip wrapper installed when you installed pip 10 in --user. That will mean changing your PATH to put that first, or using an explicit path when you invoke pip.

Python 3.7 ModuleNotFound

I'm using MSYS2 but without pip (SSL error), and when I try to run
python vin.py
It throws me this error:
Traceback (most recent call last):
File "vin.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
What can I do? Thanks in advance
I think it is because you installed the requests module for Python 3 while you are running Python 2.
To specifically install the package for Python 2, try entering this command:
pip2 install requests
or
python -m pip install requests
If you want to run the script with Python 3 instead, simply change python to python3, so:
python3 vin.py
It is better to use a virtualenv:
First create a virtualenv for your project and activate it:
python -m venv my_project
source my_project/bin/activate
Then install Requests:
pip install requests
To test: run python and import requests
>>> import requests

sudo install - Python 3?

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

ModuleNotFoundError after installing requests package

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.

Categories