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
Related
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.
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
PyCharm installed and running. Biopython package downloaded and opened in PyCharm.
pip install biopython typed in to terminal to check, SyntaxError: invalid syntax returned.
Running MacOS Mojave 10.14.2. xcode-select --install successfully installed.
Any help?
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:07:29)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> pip install biopython
File "<stdin>", line 1
pip install biopython
^
SyntaxError: invalid syntax
>>>
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!
Have both versions of Python (Legacy 2.7.10 and 3.6.2) installed on macOS Sierra.
Installed pip using the following steps.
Downloaded it using curl:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Installed pip it by running the installer script:
sudo python get-pip.py
Checked for any upgrades / updates for pip:
sudo pip install -U pip
Installed django 1.11:
sudo pip install django==1.11
When I run python (legacy):
python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.11
However, when trying it using python3:
python3
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
Note: I followed a different tutorial and got python3 working with django 1.11 using virtualenv - please don't suggest this as I am new to the python world and just want to use python3 / django 1.11 in a non-virtual environment - I just want have it working like the legacy python interpreter is behaving.
pip installs libraries differently for python2 and python3, so you effectively have different environments for each. If you want to install Django for python3, you'll want to install it like this:
pip3 install django==1.11