I'm struggling to update my default python to 3.10.6 on Mac. I seem to be able to set the 'global' and 'local' to the new one (as in code), but this doesn't impact the default...
Help would be much appreciated, please, as I'm a beginner!!
charlieharrison#MacBook-Pro-4 ~ % pyenv global 3.10.6
charlieharrison#MacBook-Pro-4 ~ % pyenv local 3.10.6
charlieharrison#MacBook-Pro-4 ~ % python
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Mar 25 2021, 03:11:28)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
charlieharrison#MacBook-Pro-4 ~ % pyenv versions
system
* 3.10.6 (set by /Users/charlieharrison/.python-version)
charlieharrison#MacBook-Pro-4 ~ %
Simpliest way is to create a link to latest version, for example:
ln -s -f /usr/local/bin/python3.10 /usr/local/bin/python
Related
I have followed all the possible suggestion on stack overflow with no success.
When I run python --version the result :
Home-Macbook-Pro:~ pcmac$ python
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Jun 5 2020, 22:59:21)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit ()
How can I uninstall or force terminal to use Python version 3.8 please
Also the IDLE is running on old Python version 2.7.16
I had the same issue and this solution worked for me:
I am using macOS Catalina version 10.15.6 and used homebrew to install python 3.8.5.
All I did was type 'nano .zprofile' in terminal and then typing: alias python='python3' and saving it by hitting Ctrl+o and then Enter.
I run into this issue ImportError numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS2_AsASCIIString installing Python in a pyenv-virtualenv environment.
In my case, it happens with the matplotlib package instead of numpy (as in the above question), but it's basically the same issue.
The answer given in that question is a simple:
Rebuild NumPy against a Python built as UCS-4.
I don't know how to do this. In this other question it is said that one has to use:
./configure --enable-unicode=ucs4
but I don't know how to use that command along with pyenv.
This issue is also mentioned in pyenv's repo issue list, and a solution given in a comment. Sadly (for me) I can not understand how to apply the fix explained in said comment.
So my question basically is: how do I build Python as UCS-4 via pyenv?
Installing python with pyenv with ucs2:
$ export PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2
$ pyenv install -v 2.7.11
...
$ pyenv local 2.7.11
$ pyenv versions
system
* 2.7.11 (set by /home/nwani/.python-version)
$ /home/nwani/.pyenv/shims/python
Python 2.7.11 (default, Aug 13 2016, 13:42:13)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_config_vars()['CONFIG_ARGS']
"'--prefix=/home/nwani/.pyenv/versions/2.7.11' '--enable-unicode=ucs2' '--libdir=/home/nwani/.pyenv/versions/2.7.11/lib' 'LDFLAGS=-L/home/nwani/.pyenv/versions/2.7.11/lib ' 'CPPFLAGS=-I/home/nwani/.pyenv/versions/2.7.11/include '"
Installing python with pyenv with ucs4:
$ pyenv uninstall 2.7.11
pyenv: remove /home/nwani/.pyenv/versions/2.7.11? y
$ export PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs4
$ pyenv install -v 2.7.11
...
$ pyenv local 2.7.11
$ pyenv versions
system
* 2.7.11 (set by /home/nwani/.python-version)
$ /home/nwani/.pyenv/shims/python
Python 2.7.11 (default, Aug 13 2016, 13:49:09)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_config_vars()['CONFIG_ARGS']
"'--prefix=/home/nwani/.pyenv/versions/2.7.11' '--enable-unicode=ucs4' '--libdir=/home/nwani/.pyenv/versions/2.7.11/lib' 'LDFLAGS=-L/home/nwani/.pyenv/versions/2.7.11/lib ' 'CPPFLAGS=-I/home/nwani/.pyenv/versions/2.7.11/include '"
I'm using pyenv, virtualenv, autoenv.
When I activated pyenv, it shows an error.
Chois#Chois-MacPro ~ $pyenv activate chacha_dabang
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(chacha_dabang) Chois#Chois-MacPro ~ $python
pyenv: python3.5: command not found
The `python3.5' command exists in these Python versions:
3.5.1
So, I checked with which:
(chacha_dabang) Chois#Chois-MacPro ~ $which python
/Users/Chois/.pyenv/shims/python
I execute python with this one :
(chacha_dabang) Chois#Chois-MacPro ~ $/Users/Chois/.pyenv/shims/python
Python 3.5.1 (default, Aug 3 2016, 11:09:57)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
It works well!!!
I don't know why it doesn't work when I type just python
Need your help.
Here is my PATH :
Chois#Chois-MacPro ~ $echo $PATH
/Usr/local/Cellar/pyenv-virtualenv/20160716/shims:/Users/Chois/.pyenv/shims:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/Chois/Library:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/Chois/phantomjs-1.9.2-macosx/bin
and .pyenv:
Chois#Chois-MacPro versions $pwd
/Users/Chois/.pyenv/versions
Chois#Chois-MacPro versions $ls
3.5.1 chacha_dabang
~$ python
bash: python: command not found
while running python2 and python 3 its showing different versions.
~$ python2
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
~$ python3
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
i think somehow default python link is broken. i can't seem to access ubuntu software center also.
Please suggest a way to fix this.
Rather than re-creating the simlink as suggested, I would start working with virtualenv. You can create virtual environment pointing at different python versions by doing:
virtualenv -p /usr/bin/python2 venv_name (for Python 2.7)
virtualenv -p /usr/bin/python3 venv_name (for Python 3)
Once you go into the venv and do the source venv_name/bin/activate, your python symbolic link will be pointed at the version you've chosen when creating it.
Also, you might find a pyvenv link which will be associated to Python 3 as this version of Python comes with virtualenv (and pip) out of the box. You might need to install virtualenv with pip (or easy install), and to figure it out which Pythonversion is your pip associated to, you can do pip --version
OSX. When I installed the Canopy IDE, Enthought Canopy Python 2.7.6 was set as the default Python for the bash shell:
$ python
Enthought Canopy Python 2.7.6 | 32-bit | (default, Sep 15 2014, 17:36:57)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Currently, I am using another IDE (PyCharm) for a project where a Python module is needed. I tried to download the module directly from the bash shell using pip but it did not work:
pip install psycopg2 <---module
I believe it has something to do with Enthought Canopy Python running, so I attempted to restore the original python. However, I could not restore it. The instructions from this Enthought post (2011) did not work:
OS X - After EPD installation, restore system python to be default
They say to comment out the following lines from the ~/.bash_profile file, save the changes and restart the bash shell:
# PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
# export PATH
Didn't work.