MacOS Catalina comes with Python 3.7.3, need to upgrade - python

I recently upgraded to macOS Catalina and it seems to come with Python 3.7.3. All of my packages have come from the PIP installed with Python 3.7.3.
I have installed Python 3.7.7 (the newest version available on Homebrew), but it gives an error when linking. It tells me to run brew link python3, and when I do, it says
Linking /usr/local/Cellar/python/3.7.7...
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
rm '/usr/local/bin/2to3'
To force the link and overwrite all conflicting files:
brew link --overwrite python
To list all files that would be deleted:
brew link --overwrite --dry-run python
Previously, I accidentally uninstalled Python 3.7.3, which many people have recommended against because it is not a good idea to uninstall the macOS bundled Python and may cause issues with the operating system. I had lost all of the packages installed using PIP, and I had to restore my computer using my Time Machine backup to avoid issues with my operating system.
How can I make the newest version of Python (3.7.7) the default, and "transfer" my packages from PIP into the newest version of Python (if that is even required) and fix my Python installation?

A Python installation of 3.7.3 came with Xcode, so all I had to do was delete the app Xcode, and I ran a fresh installation of Python using Brew.

yes you are right. New MacOs built in python3.7.3 in system and it comes from xcode, u dont't have to uninstall xcode
all you need to do is remove /lib/commandlinetools/freamwork/python3.7.3.
and install newest python with brew.
run python3 --version and pip3 --version they all newest from brew

Related

Remove newer version of python using Homebrew, keeping an older version OR using site-packages in newer version

I have used python 3.8.13 as installed by Homebrew for years, mostly with jupyter-lab for coding in notebooks. Recently I ran brew to install a package and it looks like it installed python 3.10: brew list shows both python#3.8 and python#3.10 and running python3 from the command line gives me a 3.10 session, with no knowledge of my site-packages...
I either want to:
remove python 3.10 and continue using 3.8 as I was. python#3.8 would then be the python3 command as it was before.
or
change over to using python 3.10 and have all the site-packages installed when using 3.8 "come with". In particular, jupyter-lab needs to know about them in the 3.10 environment so my notebooks keep working.
Could someone help me with either of these? I'm not familiar enough with brew or python to clearly see how to do either to completion. Thanks so much.

Installing Python 3.6 on MacOS Mojave for QGIS

I'm trying to install QGIS 3.4.1 on Mac OS Mojave. QGIS install comes as a pkg file, specifically requires python 3.6 (will not work with 3.7), Mac ships with 2.7, and homebrew installs python3 with 3.7.1.
To the Python devs out there - what's the best way of installing Python 3.6 and then QGIS here? Pyenv, venv, pipenv, virtualenv? How would QGIS always find python 3.6 - during install and later when I run it?
What I want to accomplish is run QGIS on python 3.6 and not have python 3.6 change either default Mac 2.7 python, or homebrew python3.
As stated in QGIS documentation:
The current QGIS package uses the python.org Python 3.6, at least version 3.6.5, the “macosx10.9” build - other distributions are not supported.
So you can install Python 3.6 downloaded from python.org website. Please follow these simple steps:
Prerequisites
Please verify the Xcode developer tools are installed:
xcode-select -p
should return
/Library/Developer/CommandLineTools
if not, please run this command
xcode-select --install
Python installation
Go to https://www.python.org/downloads/mac-osx/ and download the Python 3.6 macOS 64 bit installer (currently 3.6.7). This is a pkg installer you can run like many other software. If you don't want to replace the Python 3.7 you installed from brew, ensure this Python distribution is NOT added to the system $PATH. By default, it will install under /Library/Frameworks/Python.framework/Versions/3.6.
QGIS install
Now you have the correct Python installed, download QGIS package.
Install the pkg in the right order
Run QGIS and open "Preferences". Go to System > Environment.
Check "Use custom variables" and click green "plus" sign. Under "Apply", select "Prepend", set PATH as variable and paste
/Library/Frameworks/Python.framework/Versions/3.6/bin:
as Value. This will help QGIS locating the correct python interpreter. Click OK, restart QGIS and you should be done.

Python 2.7.11 pip not installed

I have Python 2.7.11 installed on my machine which to my understanding should come with pip, however when I check the C:\Python27\Tools\Scripts\ directory there is no pip.exe present.
I have tried completely removing and reinstalling Python 2.7.11 without success. Running the installer pip is set to be installed, but after the install pip is nowhere to be found.
I also have Python 3.4 installed which has pip as expected. Any thoughts?
I encountered the same problem - pip not installed - with python-2.7.16, Win10, installing for 'all users'. It was resolved when I allowed the MSI installer to target the default location (C:\Python27) rather than changing it to under Program Files (x86). I've no clue why this changed anything.
python2.7.11 should install pip into c:\python27\scripts, you can take a look here
I used https://pip.pypa.io/en/stable/installing/ to make it install. Odd that an outside body has to make a tool to get pip to install. There is no mention of pip.pypa.io on the Python web site.
Although I got error messages, it did install, so check carefully.
You also may see a message suggesting that you upgrade to pip 9.0 with the command 'pip install --upgrade.' I highly recommend that.
Also, make sure you are in the directory where pip.exe is located when you run the commands. They don't tell you that, because they assume you know that, but we're not all geeks.
For people who are running into this issue, I have a Windows 10 x86 dev box that I use for exploit development, Python 2.7 was installed due to Immunity Debugger, this install did not include the new SSL package and did not include "pip".
There was no "C:\Python27\Scripts" folder which included pip. I did have a "C:\Python27\Tools\Scripts" folder which did not have pip installed.
I tired to install pip as suggested but did not work. Best way is to uninstall Python and install newest version, currently mine is 2.7.15 which came with pip as an option. This is what solved my issue, any older version of Python will need upgraded to support the SSL packages. You will receive the same errors when you try to install pip on an older version.
If you have reinstalled Python which included the SSL package and it still does not have pip, trying installing pip this way:
1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. python get-pip.py
https://pip.pypa.io/en/stable/installing/
This should work if you have a newer version of Python.
Once you have installed pip or newer version of python, go to "C:\Python27\Scripts" and you should see pip.exe.
I have installed "python-2.7.16" in my windows 10 PC. PIP is installed under "C:\Python27\Scripts". One can add the "C:\Python27\Scripts" path to environment variable and then access pip command from command prompt.
To add the path in environment variable:
Control Panel\System and Security\System --> Advanced System Settings --> Advanced --> enviroment variables --> under system variable --> Path(variable name)
Had the issue where no matter which version of python 2.7 I installed on windows 10 there was no pip.exe generated in the "Scripts" folder.
I solved it by ensuring that that MSI Installer file had Admin privileges before installing
if pip is not installed you can use easy_install.exe to install pip and other modules
you can find easy install in
python -m easy_install pip
I had the same issue:
Installed Python 27
Tried to use pip, but failed with unrecognized command error
Checked installation: no "C:\Python27\Scripts", only "C:\Python27\Tools\Scripts"
This issue happens only on some versions of Windows.
HOW TO FIX IT:
Uninstall Python 27
Reinstall Python 27, but unselect "pip" feature
Check installation: no "C:\Python27\Scripts" as expected
Start the installer again and use "Change Python"
Set "pip" and "Add Python.exe to Path" features to be installed
Check installation: "C:\Python27\Scripts" is now correctly present
So for some unknown reason, pip is not correctly installed on some versions of Windows if it is installed during default Python 27 setup. To fix this issue, pip must be installed afterwards using the "Change Python" setup.
I meet the same issue when install Python 2.7.9. The installer does not come with pip.
Solution:
Install newer python2 x86 version: https://www.python.org/downloads/release/python-2718/
Then pip is located at C:\Python27\Scripts\pip.exe
It happens on windows as you should have admin rights to install anything on disk C.
I have the same issue Scripts folder was not installed. I would sugest to instal it on disk D.

How to install pygame, cv2, anaconda, pip etc to any one version of python in ubuntu 14.04

I have Ubuntu 14.04 LTS. I guess different versions of python are pre-installed in Ubuntu 14.04. Right now when I type 'python' in terminal it opens python 2.7.11, but I guess the default version of Ubuntu 14.04 is 2.7.6. When I type /usr/bin/python it opens the default version. I know this can be done with making aliases. The real problem is, I have installed pygame, cv2 (that is for image processing) using apt-get. These are installed for default version of python i.e python 2.7.6. Also I have installed anaconda with python 2.7.11 using pip, but again 'pip' and anaconda are installed for 2.7.11. I know python 3 is also pre-installed there but I don't use it. Also I have no python version installed in user/local/bin.Now I want to know why this problem is occurring? How can I fix this now? Also how to import all the libraries for one python version(either default or another) and how to use it? How to configure my settings so that I would not have any problem in future?
If you have easy_install installed you can run
sudo easy_install pip
to install pip. As far as installing Anaconda goes, try using this stack overflow question's answer. If you can't get that to work comment explaining the issue.
First of all I want to thanks Bennet for responding to my question so that I was able to figure out what the problem was. Actually the problem was with aliasing. When I installed cv2 or pygame using apt-get, they were installed for default version but when I installed any package by downloading the installer first (like I installed anaconda), it was installed for python 2.7.11 because 'python' was aliased for this version(that is 2.7.11). So, basically make sure that the default version for which you want to install everything is the one which is aliased as 'python', and everything goes fine. I aliased 'python' for the default version and then installed anaconda via installer and now it has been installed default version.

How can I uninstall python 2.6.5 and install the newest version(2.7.3) in ubuntu 10.04

I want to uninstall python 2.6.5, and install python 2.7.3
but there is so many other software relay on it.
so how can I up upgrade python in ubuntu10.04?
I used this link to do the same(i.e the installation part), after doing this the default python version will change to 2.7.3.
Another useful link How do I install python 2.7.2 on 10.04?.
Why do you want to uninstall the old one? You can install python 2.7 and just create a virtualenv that points to it: Use different Python version with virtualenv
Aside from that, it's rather risky to upgrade it, if you don't want to upgrade the whole system.

Categories