1

I'm trying to change the path from python 2.x to python 3.x, but my system keeps using version 2.x

I have python 3.7 and the latest version of homebrew installed. But my system is just not using the new PATH for version 3.7

My bash_profile is shown below with the last line updated as suggested on https://docs.python-guide.org/starting/install3/osx/

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH

# Setting PATH for Python 3.6   
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH  

# added by Anaconda3 5.0.1 installer
export PATH="/Users/omnidevio/anaconda3/bin:$PATH"

# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH

When I run "python --version" it only shows 2.x

Python 2.7.15

I tried to update pip to version 19, but it uses the old version 10 from python 2.7 using "pip install --upgrade pip" but got the following:

Collecting pip
 Using cached 

https://files.pythonhosted.org/packages/46/dc/7fd5df840efb3e56c8b4f768793a237ec4ee59891959d6a215d63f727023/pip-19.0.1-py2.py3-none-any.whl

matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
Could not install packages due to an EnvironmentError: [Errno 13] 
Permission denied: '/Library/Python/2.7/site-packages/pip-10.0.1- 
py2.7.egg/EGG-INFO/dependency_links.txt'
Consider using the `--user` option or check the permissions.

You are using pip version 10.0.1, however version 19.0.1 is 
available.
You should consider upgrading via the 'pip install --upgrade pip' 
command.
ultimahex
  • 11
  • 3
  • Try running `type python` to see what your shell is running when you invoke Python. – Mark Setchell Jan 29 '19 at 08:03
  • The output is as follows: python is /usr/local/bin/python – ultimahex Jan 29 '19 at 09:39
  • That means your `PATH` has got `/usr/local/bin` before `/Library/Frameworks/Python.framework/Versions/3.6/bin` so it uses that when you type `python`. Furthermore, if you run `ls -l /usr/local/bin/python` I guess you will see a symlink to `.../Cellar/...` which means that was installed by **homebrew**. – Mark Setchell Jan 29 '19 at 09:43
  • output is as follows: lrwxr-xr-x 1 root wheel 68 30 Oct 18:38 /usr/local/bin/python -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python So, if I change the order of python versions in my .bash_profile, it will work? – ultimahex Jan 30 '19 at 01:33
  • Yes, that's correct. Start a Terminal **and keep it open till everything works**. Then edit your profile, start a new Terminal and try `python` in the new Terminal. Keep opening new terminals and trying till you are sure it is correct, then close the initial Terminal. If you do it that way, you'll always have a working Terminal available till all issues are resolved. – Mark Setchell Jan 30 '19 at 07:38

0 Answers0