Unable to install an older version of python - python

I already have python 3.6.8 and 3.7.3 installed on Windows 10. I had used the "executable installer" from the downloads page to install it.
I have a requirement where I need to install 3.7.1, unfortunately when I use the installer to install python 3.7.1, it complains that "another version of this product is already installed".
How can I install python 3.7.1 without uninstalling 3.7.3?

Have you tried using a virtual environment? This would resolve your problems nicely. Below are the command line steps to create/activate one on Windows.
pip install virtualenv
virtualenv mypython
mypthon\Scripts\activate
If you don't already have pip, use:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
This should resolve your problems, as you can run one version on your vm, and another on your local computer. Let me know if you have any questions!

Related

Can't get pip to work after installing newer python

I installed python 3.8 in a different location than 3.7, and later uninstalled 3.7 while trying to troubleshoot issues with pip. I can't get pip to respond to install any modules now. It keeps referencing its old python 3.7 location and I don't know how to make it focus on the 3.8 installation location.
Here are the errors I'm encountering:
>pip --version
Fatal error in launcher: Unable to create process using '"c:\program files\python37\python.exe" "C:\Program Files\Python37\Scripts\pip.exe" --version': The system cannot find the file specified.
>python get-pip.py
Collecting pip
Using cached pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
Uninstalling pip-20.1.1:
Successfully uninstalled pip-20.1.1
Successfully installed pip-20.1.1
Now when I call pip --version is gives me the original error.
And just for more information, here are two more calls which might help troubleshoot.
>which python
/c/Users/patch/AppData/Local/Programs/Python/Python38/python
>python --version
Python 3.8.3
I just want to be able to use pip again to install modules. I'm learning some python and this pip issue is really slowing me down.
I'm open to completely uninstalling python and scrubbing the system of traces of both I just don't know what's the safest and most likely to work option.
Use
python -m pip --version
python -m pip install PACKAGE_NAME
This will use the pip that is associated with the newer python.
I suggest using the python -m pip install command over pip install because it is more clear which python version is being used.
I'd recommend scrubbing 3.7 and 3.8 from your system, then reinstalling the versions you need with pyenv (if you're using the Windows Subsystem for Linux) or pyenv-win (if not on WSL) to manage multiple Python versions. It checks the directory-specific version of Python that you've set before deciding which version's executables to use for Python, pip, etc. This solution will also work in the long term for future versions of Python you may want to install.
Future installations using pyenv or pyenv-win would involve commands like pyenv install 3.8.1. For a full list of available versions you can run pyenv install -l.
#jakub's solution will work if you want an immediate, but short-term, fix.

Pip broken after deleting python3.7 folders

I think I broke my pip after desperately trying to uninstall Python3.7. (I am on a Mac)
I removed the python folder from the application, removed /Library/Frameworks/Python.framework and removed the folders from /usr/local/bin according to https://osxuninstaller.com/uninstall-guides/properly-uninstall-python-mac/. I then installed python3.6.
src$ pip3.6 --version pip 9.0.1 from
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
(python 3.6)
but pip itself does no longer work.
src$ which pip
/usr/local/bin/pip
src$ pip --version
-bash: /Library/Frameworks/Python.framework/Versions/3.7/bin/pip: No such file or directory $
It still references the python 3.7 folder. How can I unlink that reference? THe same is btw. true for the package virtualenv that I installed. I can install it with pip3.6 but calling virtualenv still references to the framework folder of 3.7
You need to install pip in that environment. i.e 3.7.
Reason is when you deleted the default install you deleted the dependencies/ libraries that came with it.
Easiest way is to install python afresh via homebrew if you have it.
brew install python
Alternatively you can follow the instructions here to download a file to install pip securely. Homebrew can become messy when managing python environments. I'd recommend looking at something like anaconda if you are going to using different python versions with their own dependencies etc.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
Other options for fresh install are described in answer here. Hope that helps.
How do I install pip on macOS or OS X?

How to fix broken python 2.7.11 after OSx updates? An in-depth look into Homebrew and beyond

What happened:
After an OSx update and installing a new version of python 2.7 my virtualevn environment completely broke and I struggled in fixing it. I wasn't sure what caused it and went through a whole set of things that I did and read initially that didn't work are listed below. What solved my problem is provided in the answer section.
What didn't work to fix virtualenv command not found:
Installed python through homebrew and then used pip to install virtualenv
Installed python through https://www.python.org and then used pip to install virtualenv
Related questions that helped me but did not provide the solution to my problem:
virtualenv-command-not-found
virtualenv-workon-command-not-found
Complete manual recovery I went through (What not to do!):
This didn't completely solved my problem. It is just to give you an idea of what steps I went through before I found the correct way to fix my python dev environment on my OSx.
Removed python 2.7 by using the post in here
Removed the homebrew installed version
Installed python through the pkg file in Mac OS X 32-bit i386/PPC installer or Mac OS X 64-bit/32-bit installer
Manually installed virtualenv following the instructions from here:
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-13.1.2.tar.gz
tar xvfz virtualenv-13.1.2.tar.gz
cd virtualenv-13.1.2
sudo python setup.py install
Manaully install pip through 7:
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
PIP was still broken after all this:
After all this after creating a virtual environment my pip still installed the packages in the main python folder instead of installing them under the virtual environment and non of the threads here neither here helped. My solution to that was to run pip under my virtual env with the following options:
1- Activate the virtual environment so that $VIRTUAL_ENV is set:
source venv/bin/activate
2- Forces pip to install in the right destination:
pip install --target=$VIRTUAL_ENV/lib/python2.7/site-packages
Summary
Something was badly broken and best way I fix my dev environment is provided in the answer to this question.
The reason
In my case was an OSx upgrade that affected my homebrew and after upgrading to python 2.7.11 is didn't install it properly.
How I got it to work:
I found steps 3 and 4 in a thread here and many thanks to https://github.com/baronomasia.
1 - Removed python 2.7 by using the post in here
2 - Removed the homebrew python installed version
brew uninstall python
3- Reinstall your Xcode command tools:
sudo xcode-select --install
4- Upgrade homebrew and reinstall python through homebrew:
brew update && brew reinstall python
After doing brew upgrade python my system python was broken and was throwing fits about virtualenvwrapper.sh, as well as my pip command was just suddenly missing.
I went to python.org and downloaded the python 2.7.13 installer, ran it, I now have python 2.7.13, pip, and can run pip install virtualenvwrapper and things seem to work.

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