MacOS stil points to python3.6 - python

I can confirm I installed python3.8
brew install python
Warning: python#3.8 3.8.5 is already installed and up-to-date
To reinstall 3.8.5, run `brew reinstall python#3.8
However, macOS still points to python3.6
$python --version
Python 3.6.8 :: Anaconda, Inc.
$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
What's the workaround to point to version 3.8?

Pretty certain the simple fix here since your path is small is to get rid of the
/anaconda3/bin and /Users/Sani/anaconda3/bin in your PATH variable.
Try this:
export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/anaconda3/bin" | tr "\n" ":"); echo ${p%:})
We are taking whatever is inside the grep command and removing it
export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/Users/sani/anaconda3/bin" | tr "\n" ":"); echo ${p%:})
You may need to restart your terminal to see if it changed. I assume the Python3.6 is being picked up through the Anaconda bins.
Otherwise yes uninstalling Anaconda3 will solve your problem.

I have found a way out
conda install python=3.8
works for me.
$ python
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Related

Uninstall conda without using conda

I messed up my conda installation and now there is no file named python in anaconda3/bin directory.
$ conda info -a
/home/username/anaconda3/bin/conda: line 2: /home/username/anaconda3/bin/python: No such file or directory
$ which python
/usr/bin/python
$ python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
When I enter the anaconda3/bin directory I can see the following files:
$ ls | grep python
ipython3.c~
ipython.c~
python3.9.c~
python3.9-config.c~
python3.c~
python3-config.c~
python.c~
I want to uninstall conda and start over but I can not use conda to install anaconda-clean with which I could uninstall conda. How can I uninstall conda completely to get rid of all inconsistencies and problems I created?

How to setup python3 version on mac?

I have installed python 3.8.0 via pyenv.
pyenv which python
/Users/myname/.pyenv/versions/3.8.0/bin/python
If I run python3 I get
python3
Python 3.6.8rc1 (v3.6.8rc1:cc3e73212a, Dec 11 2018, 17:37:34)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
If I check
which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
How can I set the 3.8.0 version as default?
By typing pyenv global 3.8
You check get the list of options by typing pyenv -h
If you have multiple versions of python installed, you can do python -3.x -m ...
Also check if the env is active before opening it.

Move from python 2 to python 3 on Mac

I have both python 2.7.16 and python 3.7.3 on my Macbook air.
I don't use python 2.7.16 so I want to remove it, but I understood that this could break my Mac.
I am frustrated from using python3 and pip3 instead of python and pip is there a way to make all of the python3 commands to be accessed by using python (without 3) instead of python 2 and make python 2 be accessible by using python2?
tnx ahead
(base) shrub$ /usr/bin/py
pydoc python python2.7 pythonw
pydoc2.7 python-config python2.7-config pythonw2.7
Looking in /usr/bin there is a python executable (which when run opens a shell with python3) and a python2.7 executable (which when run opens a shell with python2).
(base) shrub$ python
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
(base) shrub$ python2.7
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Running python scripts with python (python hello.py for example) should default to python3 and running scripts with python2.7 (python2.7 hello.py for example) will run them with python2.
Also there is a script called 2to3 which can help you with converting your python2 code to python3 :)
https://docs.python.org/3.0/library/2to3.html

Did installing Miniconda destroy Python 2.7 on my Mac?

Have I lost Python 2.7 and does Mac OS still need it? If so, how do I fix this?
I'm a longtime Python 3.x user on Mac OS. I wanted to try Miniconda3 to see if I could recommend it to Mac and Windows students (non-CS). Now I when I try $ type -a python3 I get:
python3 is /Applications/miniconda3/bin/python3
python3 is /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
python3 is /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
python3 is /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
python3 is /usr/local/bin/python3
Try $ type -a python2 and get:
-bash: type: python2: not found
Try $ type -a python and get:
python is /Applications/miniconda3/bin/python
python is /usr/bin/python
I used the Miniconda 64-bit (.pkg installer) under Python 3.7 here:
https://docs.conda.io/en/latest/miniconda.html
Type /usr/bin/python and:
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Okay, it's all good. Thanks, juanpa.arrivillaga!

"python" command can't find Python2 installation

I have screwed up my python install on my MacOS machine.
Here it is -
REMs-MBP:opt rem$ which python
/usr/bin/python
REMs-MBP:opt rem$ python
-bash: /usr/local/opt/python/libexec/bin/python: No such file or directory
REMs-MBP:opt rem$ which python2
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
REMs-MBP:opt rem$ python2
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
python2 works fine but default python is not working fine.
How can I fix it?
brew install python by default tries to install python3. I need python2.7 as my default.
Updates:
pip still pointing to python3 installation.
PREMs-MBP:opt prem$ which python
/usr/bin/python
PREMs-MBP:opt prem$ pip
-bash: /usr/local/bin/pip: /usr/local/Cellar/python/3.7.0/bin/python3.7: bad interpreter: No such file or directory

Categories