简体   繁体   中英

Installed python package with pip but can't import said package

I installed a python3 package called urllib3 using pip with the following command:

pip install urllib3

It seemed to be successful and when I type the command:

pip list

I get the following list which implies it is installed

错误

But when I try to import in in the python console I get the following error:

ModuleNotFoundError: No module named 'urllib3

I am using Python 3.8.5 (64bit) with a VS Code virtual enviroment, I have tried uninstalling it and reinstalling I've also checked typos but I can't seem to find any.

try:

pip3 install urllib3

As it can be possible you have also installed python2 on your machine.

Also try restarting your IDE.

You're paths might be mixed up: python, python3 as well as pip and pip3 might not point to the places you're expecting.

Try to validate that which pip and which python point to the same python installation.

Alternatively, you can install urllib3 using python -m pip install urllib3 instead of pip install urllib3 .

Lastly, it might be a VS Code issue. See if the information on selecting a Python interpreter are helpful to you.

The problem was with permissions for running scripts on the computer, I had to run the following command to enable permissions on my system:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

This enabled the current user (me) to actually activate the venv when I opened powershell (I think) and run the pip install inside the venv instead of outside.

Note that I had the package installed globally since the PowerShell was not inside the venv.

Thanks for the help

Resolved!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM