I have installed python3.8 to python 19.10:
sudo apt install python3.8
I now want to install pip for python 3.8
python3.8 -m pip install pip
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (18.1)
But the pip 3 is 3.7
pip3 -V
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
So that, for example :
pip3 install pyinotify
Requirement already satisfied: pyinotify in ./.local/lib/python3.7/site-packages (0.9.6)
Attempting to import pyinotify to a python3.8 script throws a ModuleNotFound
error
In order to make sure you are using the correct pip, please use it as follows:
Brett Cannon, one of the Python core developers, just recently published a blog article about this topic: https://snarky.ca/why-you-should-use-python-m-pip/
This all said, you usually want to install Python packages into a virtual environment, not in the system Python.
https://realpython.com/python-virtual-environments-a-primer/
sudo apt install python3-pip
orpython3.8-pip
.Let the system manage your Python version.
Edit:
The original question was trying to install
pip
viapython -m pip
, and after the original poster usedapt
, the system package manager, instead, they were able to getpip
working correctly.As noted in the comments and in jugmac00's answer, it is now recommended to use
pip
by calling as a Python module:If multiple versions of Python are installed on the system and this isn't the default version, you may need to specify the version:
Have you tried using Miniconda or Anaconda?
In a nutshell, it's a good way to test different python versions and you won't have to worry about messing up your system python (projects/installers that make use of the keyword
python
).source ~/miniconda3/bin/activate
intel
andconda-forge
to find packages there:conda config --add channels intel && conda config --add channels conda-forge
conda create -n py38 python=3.8 pip
pip-19.3.1-py38_0
conda activate py38
python
while inside this environment, it will use the interpreter you set up. Also,pip install
andconda install
will be directed to yourpy38
environment until youconda deactivate
or switch.Here's the output when I ran
conda create -n py38 python=3.8 pip
.I also did
pip install pyinotify
to address your import inquiry,python -c "import pyinotify; print(pyinotify.__version__)"
gave me0.9.6
.I just solved this problem by myself because I couldn't find a simple way to make this right.
Because of Python3.7 installed first, and Python3.8 is not going to replace old pip when you install it.
Try to look up the location of pip3
In my case(macOS), it's located at /usr/local/bin/pip3
If you installed python3.8 pip properly, you're supposed to see pip3.8
If you do, try to remove it.
And copy pip3.8 with a new name, pip3
That's it!!!
I'm not sure is it a perfect solution, but it works for me.
As suggested in official documentation you can try with get-pip.py.
This will install pip as pip3.8
I had the very same issue. I think the best practice is to call pip from within the python installation, which forces you to be specific on the version of python in which to install the library, ie.
Alternatively, you can change the default python installation so that pip3 will refer to python3.8. For managing python versions you can use update-alternatives:
Now you will have to select the default version. Run the following and press 2
pip3 should now refer to your python3.8 package