How to change Python version in which modules get installed? - python

I'm trying to install Python-Twitch for Python 3.4. I have both 3.4 and 3.5 installed on my computer, and in command prompt I do this:
python --version
Where it gives me Python 3.5.x. Then:
set PATH=C:\Python34\;%PATH%
And python --version will then read Python 3.4.x.
Once I do 'pip install python-twitch', it installs it to the Python 3.5 Lib/Site-Packages folder. How would I get this over to 3.4?
Thanks so much for any help.

I think this was already answered: pip: dealing with multiple Python versions?
Since version 0.8, Pip supports pip-{version}. You can use it the same as easy_install-{version}:
$ pip-2.5 install myfoopackage
$ pip-2.6 install otherpackage
$ pip-2.7 install mybarpackage
EDIT: pip changed its schema to use pipVERSION instead of pip-VERSION in version 1.5. You should use the following if you have pip >= 1.5:
$ pip2.6 install otherpackage
$ pip2.7 install mybarpackage
Check https://github.com/pypa/pip/pull/1053 for more details

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.

How to install python packages from older version to newer version?

i was working with python 3.7 and i installed recently python 3.8 in linux.
Is there any bash command or script that take a list of all packages of 3.7 and install it one by one in 3.8 version.
i want to avoid to do it by hand every package.
Note: i install them in my system not using venv.
Thanks!
/path_to_3.7_bin/python -m pip freeze > /home/packages_list.txt
then
/path_to_3.8_bin/python -m pip install -r /home/packages_list.txt
try https://pip.pypa.io/en/stable/reference/pip_freeze/
pip freeze > requirements.pip in the old version
pip install -r requirements.pip in the new version

Installing to specific sub-version of python

I'm trying to use pip to install a program specifically to python 3.6.4, but when I run
py -3.6 -m pip install package
It installs to 3.6.1
However, if I try to specify the specific version of 3.6 I want with
py -3.6.4 -m pip install package
It returns this output
Unknown option: -3
I'm guessing the argument for the version does not allow for the second period or something, but does someone else know a way to get around this? I'd prefer to do this without uninstalling 3.6.1
You can use pyenv
You should isntall pyenv and run these command
pyenv install 3.6.4
pyenv global 3.6.4
python -m pip install package

numpy got installed in Python3.5 but not in Python3.6

I have both Python 3.5 and Python 3.6 on my laptop. I am using Ubuntu 16.04. I used pip3 to install numpy. It is working with Python3.5 but not with Python3.6. Please help.
To install via pip for specific python version use:
py -(python-version) -m pip install numpy
in your case
py -3.6 -m pip install numpy
Make sure that your Python is Python 3.6:
python --version
Python 3.6.4
Now install with:
python -m pip install numpy
This will run the pip for the current Python the option -m imports the module pip and runs it as it would be pip as command line app.
Cannot comment since I don't the rep.
If your default python is 3.5 when you check python --version, the way to go would be to find the location of the python executable for the desired version (here 3.6).
cd to that folder and then run the command given by Mike.

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

Categories

Resources