Installed module using pip, not found

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 09:41:39

Make sure you're installing it for the version of python you're using, with

/path/to/your/python -m pip install <package>

The issue could be that the version of python you used to install the module does not match the version python you are trying to import from.

  1. Find out whether the module in the python version you wanted you can try using the command: pip3 freeze to get the list of packages installed for version of python(In your case, it is python3.5).

  2. Before that, check different versions of python installed in your machine. You can use the command locate /python | grep /bin if you have python2.7 and python3.5, then you should use the corresponding pip/pip3 to install the modules.

  3. Open the corresponding python shell (python3) and try to import again

I had a similar problem with PyCharm, where the dependencies I installed using pip would work for the editor windows (i.e., there were no error reports about imports), but the project would complain about the dependencies when I tried to run it. Turns out, I set up a virtual environment for that project after I created the tasks that ran my project and tests. I had to go to the window where you set up the tasks and make sure that all of them used the correct venv. Hope this is useful.

The module may be installed but the program doesn't run. This happens because of 2 different versions of python co-existing. So run your Py Script with the location of the python version you have installed the module for, say usr/bin/python python.py or /usr/bin/python3 python.py.

Hope this helps in your progress!

pip needs python, and sometimes the python you are trying to execute your *.py may not be same as the python binary used by pip.

Can you retry installing following these steps:

which python

Let's say it prints:

/usr/bin/python

Means you can use:

/usr/bin/python -m pip install <package>

Or you can try to choose from the different versions you have of python.

Now try executing you *.py using

/usr/bin/python *.py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!