pip3 list for various python installations - python

When running pip3 list it shows packages installed for default python3.5, but I want it to show installed packages for another python installation, for example python3.6, which libs are located at /usr/lib/python3.6, how I can do this?

You'll have to run Python 3.6's pip.
On windows this is:
py -3.6 -m pip list
on MacOS/Linux I believe it is
python3.6 -m pip list
but substitute in whatever call you make to get to your Python3.6 interpreter.

Related

Connection between pip and python [duplicate]

I'm now currently using Python on Ubuntu 15.10.
But in my OS, I have many different python versions installed:
Python (2.7.9)
Python3 (3.4.3)
Python3.5
PyPy
So, it got messy with the versions of the packages in different environments. For example, if I run:
pip3 install django
But in fact, I cannot import django inside python3.5.
Is there any efficient way to call the correct version of pip?
Note:
Don't suggest that I use virtualenv, I know about it and am seeking another solution.
Finally I found the solution myself, see the Docs:
https://docs.python.org/3/installing/index.html?highlight=pip#work-with-multiple-versions-of-python-installed-in-parallel
Just call:
pythonXX -m pip install SomePackage
That would work separately for each version of installed python.
Also, according to the docs, if we want to do the same thing in windows, the command is a bit different:
py -2 -m pip install SomePackage # default Python 2
py -2.7 -m pip install SomePackage # specifically Python 2.7
py -3 -m pip install SomePackage # default Python 3
py -3.4 -m pip install SomePackage # specifically Python 3.4
How about using pyenv?
You can switch the version.
$ pyenv install 2.7.X
$ pyenv install 3.5.X
$ pyenv local 2.7.X
$ pyenv global 3.5.X
This solution worked for me:
sudo python2.7 -m pip install [package name]
Why not using anaconda?
If you use conda, you can easily create/manage virtual env. For example, if you have root env python 3.4 and py27 env for python 2.7, you can easily switch between them use command source activate [env]
source activate py27
conda install SomePackage

Error says the running Python is 3.4, but 3.5 is installed

I am trying to update the module vpython to the most current version. I run:
pip3 install --user vpython --upgrade
in a Jupyter terminal. This gives the error:
ERROR: jupyter-server-proxy requires Python '>=3.5' but the running Python is 3.4.2
But when I run:
python3 --version
it returns:
Python 3.5.2 :: Anaconda 4.1.1 (64-bit)
Is there something going wrong with the installed Python3 kernel for Jupyter?
Change the environmental variable in your control panel just a simple conflict between python 3.4 and 3.5 this will surely solve your issue.
The issue is that you are using pip3 which is not always tied to the specified python you are trying to run. pip is a module installed with each python3 instance, so to specify it to install to a python environment, use the -m flag:
python -m pip install <module>
Where python is the python that you expect. For instance, if you want it to run against the installation that you use through python3, then you would do python3 -m pip install <module>. This makes things easy to track, since if you want to see which python you are installing to, you can use python -m pip -V. On my machine that outputs:
pip 19.3.1 from /Users/mm92400/anaconda3/lib/python3.6/site-packages/pip (python 3.6)

Install OpenCV for systemwide Python on MacOS

I have three versions of python:
python (2.7.10, default systemwide version shipped with MacOS)
python2 (2.7.15, installed with brew)
python3 (3.6.5, installed with brew)
I installed opencv for python2 and python3 using pip2 and pip3, respectively. However, I have a matlab application (VOT-toolkit) which generates a command as: /usr/bin/python -c "import cv2" which fails since /usr/bin/python refers to the systemwide python version which does not have opencv installed.
Is there a way I can install opencv for the systemwide python version? (If possible, directly using pip without having to build from sources)
Thanks!
Probably your pip2 points to the newer installation. One can use the specific pip of the installation or one can invoke pip using python. I prefer the later, since this is 100% certain that it will be installed for the correct python installation. To do it, you only need the path to the python installation which you want to use and write the following code:
/path/to/python -m pip install package
or in your case:
/usr/bin/python -m pip install opencv-python
In some weird cases pip is not install and you can do (python >= 2.7.9 or 3.4):
/usr/bin/python -m ensurepip
You may need permission to use this command so you can do it with sudo or any other way to ensure the permissions are met.

I have python 2.7 and 3.6 installed on my mac. How to find the version of pip associated with Python3?

I tried using pip --version but it will give me the version of only pip associated with python and not python3.
Try using pip3 --version. Normally pip3 is the symlink to the pip associated with Python3. If that doesn't work, please provide more details as to how you installed the python versions.
You can run the following command, where you can update the program python to whatever python program you have
python -m pip --version

Install/use pip for specific version/location of python

For whatever lame reason, I have a bunch of different versions of python installed. The one I want to use (and what my current $PATH is using) is at /opt/python2.6/bin/python. How do I install 'pip' for this version so when I do a 'pip install package' it goes to the right location?
When you have multiple versions of Python with pip installed, you can launch pip using your Python executable:
$python2.6 -m pip [pip-args]
To install pip for a specific Python version, run get-pip.py (https://bootstrap.pypa.io/get-pip.py) with the respective Python executable:
$python2.6 get-pip.py

Categories