Python pip install module is not found. How to link python to pip location?
As a quick workaround, and assuming that you are on a bash-like terminal (Linux/OSX), you can try to export the PYTHONPATH environment variable:
export PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages"
For Python 2.7
Unable to import a module that is definitely installed
In my case, it is permission problem. The package was somehow installed with root rw permission only, other user just cannot rw to it!
Why am I getting ImportError: No module named pip ' right after installing pip?
Just be sure that you have include python to windows PATH variable, then run python -m ensurepip
Module not found even if it is in pip
Yes I found myself the solution. Thanks to @user42 for the link. I used this command and it worked.
pip install --upgrade google-api-python-client
I have put the answer because it may help people who are facing or will be facing the same problem.
Python - Module Not Found
All modules in Python have to have a certain directory structure. You can find details here.
Create an empty file called __init__.py
under the model
directory, such that your directory structure would look something like that:
.
└── project
└── src
├── hello-world.py
└── model
├── __init__.py
└── order.py
Also in your hello-world.py
file change the import statement to the following:
from model.order import SellOrder
That should fix it
P.S.: If you are placing your model
directory in some other location (not in the same directory branch), you will have to modify the python path using sys.path
.
Module not found error in Python after pip install package --user
You're probably attempting to download package to a system folder where you don't have permission to write or modified, maybe it's due to modification on your pip.ini
file which specify by default the packages location ?
Check pip documentation and his topic about configuration here.
Furhtermore, I advise you, if you start learning python and using pip package, to learn fundamental about the principle of virtualenv using venv lib here. VirtualEnv is a recommended practice in python who allow you to compartmentalize project in a specified place with a personal pip package directory and other things, these methods aim to avoid dependancy concurrence between projects and also avoid pip package permissions issue by downloading pip package only for your virutalenv.
- Step by step to setup venv ( you should be in the root folder of your
projet) :
user@hostname > python3 -m venv venv
user@hostname > source ./env/bin/activate
(venv) user@hostname > python -m pip install foo-packages
- Or the second option but not recommended is to use sudo to
install packages to the system folder :
sudo@hostname > sudo python -m pip install foo-packages
pip' is not recognized as an internal or external command
You need to add the path of your pip installation to your PATH system variable. By default, pip is installed to C:\Python34\Scripts\pip
(pip now comes bundled with new versions of python), so the path "C:\Python34\Scripts" needs to be added to your PATH variable.
To check if it is already in your PATH variable, type echo %PATH%
at the CMD prompt
To add the path of your pip installation to your PATH variable, you can use the Control Panel or the setx
command. For example:
setx PATH "%PATH%;C:\Python34\Scripts"
Note:
According to the official documentation, "[v]ariables set with setx variables are available in future command windows only, not in the current command window". In particular, you will need to start a new cmd.exe instance after entering the above command in order to utilize the new environment variable.
Thanks to Scott Bartell for pointing this out.
Related Topics
Why Doesn't a Python Dict.Update() Return the Object
How to Resolve Typeerror: Can Only Concatenate Str (Not "Int") to Str
Multiple Variables in a 'With' Statement
What Is the Point of Indexing in Pandas
Cannot Find Vcvarsall.Bat When Running a Python Script
Want to Find Contours -> Valueerror: Not Enough Values to Unpack (Expected 3, Got 2), This Appears
How to Login to a Website with Python
How to Convert CSV File to Multiline JSON
Appending a Dictionary to a List - I See a Pointer Like Behavior
Calculate Average of Every X Rows in a Table and Create New Table
If X:, VS If X == True, VS If X Is True
How to Set Class Attributes from Variable Arguments (Kwargs) in Python
Let JSON Object Accept Bytes or Let Urlopen Output Strings
Python Pip Install Module Is Not Found. How to Link Python to Pip Location