pip install, installing packages for other python version - python

I am working on a GPU instance on AWS. There are some already provided Conda environments. I am using tensorflow2_latest_p37 environment.
This environment has 2 python 3 versions .i.e python 3.6 and python 3.7.
All the preinstalled packages are available in python 3.7
But whenever I am trying to do pip install dlib it would install it for python 3.6.
How can I install this for python 3.7?

Run the command:
which python.
Probably it will show you python3.6,
it means that your default python version is 3.6.
You need to search your pip3 path.
path/to/pip3 install dlib.

If you know how to use the Python 3.7 environment, you can simply use python -m pip install ... or more exactly:
command_for_python3.7 -m pip install package_name
If unsure, you should search for commands starting with python in /bin, /usr/bin and /usr/local/bin. You could also have Python installations under /opt.
On Windows, the magic word is py:
py 3.7 -m pip install package_name

Related

Is there a way to change which pip to use at this project?

I'm trying to make a pip install of the fastf1 library. I noticed that I was using py 3.7 and that lib requires 3.8 or superior. I updated my interpreter (to python 3.10) but, the pip install keeps returning "ERROR: Could not find a version that satisfies the requirement fastf1". My python --version returns 3.10, but my pip version, although updated, still calling the anaconda's pip
How do I change the main pip to be used in this project?
Terminal result:
PS C:\Users...\Github\speedmetrica\DataAnalysis> python --version
Python 3.10.0
PS C:\Users...\Github\speedmetrica\DataAnalysis> pip --version
pip 21.3.1 from c:\users\jgbal\anaconda3\lib\site-packages\pip (python 3.7)
If python --version is running the desired version of Python, instead of running:
pip install packagename
run:
python -mpip install packagename
That runs the pip module installed for that version of Python as the entry point using the same Python executable you've been running, so it will install for that version of Python as well.
If you're on Windows, and installed as admin to install the Python launcher for Windows, you can be avoid relying on the PATH having a specific version appear first by running:
py -3 -mpip install packagename
which will run the latest installed version of Python 3. Changing to:
py -3.10 -mpip install packagename
will force it to run the latest installed copy of Python 3.10 specifically.

Install Python Module in non-default Python Instance (Multiple Instance Installed)

I have installed Python 3.8.5 and 3.7 on my computer. By default, it's 3.8.5. So anything that I pip installed is all for 3.8.5. However, I need to install some modules into 3.7 as well.
How can I install modules to that version?
Try this in your terminal or anaconda prompt:
python3.7 -m pip install moduleOfYourChoice

How to install pip with a specific python version

I want to install pip for python 2.7, but I am also having python 3.x but both locations are different. when ever I install or update the pip It is installing in the python 3.x location.
How to install pip for python 2.7?
I recently found the following solution, when you are maintaining python2.x and python 3.x in host system. You can find the pip under Scripts folder.
Try pip --version it gives pip version and python version as well
If you want to install package using pip use the following commands.
python -m pip install package_name
python2.x -m pip install package_name
Which reads the specified python pip module to install the package

Install python module for non-default version on linux

I have different python versions installed on my ubuntu machine. The default version is 2.7.
So when I install any new python module, for example using:
#apt-get install python-nfqueue
it will be istalled just for the default version (2.7)
How can I install the new modules for the other versions?
Is there a way to do it using apt-get install?
Thank you!
You should install Python libraries with the Python package installer, pip.
Create a virtualenv with the Python version you want to use, activate it, and do pip install NetfilterQueue. You'll still need to install the system dependencies (eg libnetfilter-queue-dev in this case) with apt-get.
You can install pip to work with different versions of python. Here is a link to the pip read the docs page(http://pip.readthedocs.org/en/latest/installing.html).
to install pip to the default version of python on your machine:
python get-pip.py
to install for non standard versions call python with the version you wish to install for:
python33 get-pip.py
you can then run pip for python version 3.3 by calling
pip33 install pythonmodule

Installing pip with correct python version

I am on shared hosting and I need to install pip with the correct python version, 2.7. To install pip, I did:
$ easy_install pip
However, after it was installed I get the following:
[dave#web1 lib]$ pip --version
pip 1.0.2 from /home/premiere/dave/financials/lib/pip-1.0.2-py2.7.egg (python 2.4)
How would I re-install pip to work on the python2.7 version, which is also installed on the machine?
[premiered#web1 ~]$ python --version
Python 2.6.6
Which is strange, since it is installing to python2.4.
You may want to create a virtualenv using -p /path/to/python-2.7.binary param, and then activate it. Then all stuff you installed using pip would be correctly into your virtualenv.
If multiple versions of python are installed on the system, then you should invoke the version you want when installing. i.e.
$ python27 easy_install pip
This creates a pip file in your path that contains the specified version of python in the hashBang line.

Categories

Resources