Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use pyenv to manage multiple Python versions on Ubuntu/Mac #249

Closed
cztomczak opened this issue Sep 17, 2016 · 0 comments
Closed

How to use pyenv to manage multiple Python versions on Ubuntu/Mac #249

cztomczak opened this issue Sep 17, 2016 · 0 comments

Comments

@cztomczak
Copy link
Owner

cztomczak commented Sep 17, 2016

Tested with Ubuntu 14.04 and Mac 10.9.

pyenv: https://github.com/yyuu/pyenv

Install on Linux: https://github.com/yyuu/pyenv-installer

Don't forget dependencies on Linux: https://github.com/pyenv/pyenv/wiki/common-build-problems

Install on Mac with Homebrew: https://github.com/yyuu/pyenv#homebrew-on-mac-os-x

Add pyenv to ~/.bashrc . Do not add the eval "$(pyenv virtualenv-init -)" line otherwise pyenv is broken then.

.bashrc for Linux:

export PYTHON_CONFIGURE_OPTS="--enable-shared"
export PATH="/home/cz/.pyenv/bin:$PATH"
eval "$(pyenv init -)"

.bash_profile for Mac:

export PYTHON_CONFIGURE_OPTS="--enable-framework"
export PATH="/usr/local/bin:/usr/local/git/bin:$PATH"
eval "$(pyenv init -)"

Python must be built as shared library on Linux and as framework on Mac

Python must be built as shared library on Linux, and as framework on Mac. See this explanation by Robin Dunn: wxWidgets/Phoenix#288 (comment)

Build options explained on pyenv wiki page:
https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with-framework-support-on-os-x
https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with---enable-shared

Continued

Install multiple Pythons. Before proceeding install required packages listed here: https://github.com/yyuu/pyenv/wiki/Common-build-problems

pyenv install --list
pyenv install 3.4.5
pyenv install 3.5.2

Change Python version in current terminal (shell), in current directory (local, creates .python-local file) or globally (global):

pyenv shell 3.4.5
pyenv local 3.4.5
pyenv global 3.4.5  <-- using global is recommended

Issue with sudo

It doesn't work with sudo. But it shouldn't matter, because when installing python package you don't need to use sudo, as Python is installed in ~/.pyenv and doesn't require root privileges.

Update pyenv

You need to update pyenv so that you can install new Python versions available. When executing pyenv install --list I didn't see latest Py 3.6 rc1. I had to run pyenv update to be able to install it.

Homebrew

Mac notes for Homebrew:

  • Install GUI toolkits for the Homebrew Python: brew install python, brew install wxpython, brew install pygtk, brew install gtk+3 pygobject3, etc.
  • To install GUI toolkits for Homebrew's Python 3 type: brew install python3, brew install gtk+3 pygobject3 --with-python3.
  • To install PySide for Qt4 type: install Qt 4.8.5 dmg and type sudo pip install pyside==1.2.2. If there are errors when importing library add pyside directory to DYLD_LIBRARY_PATH or run the pyside postinstall script manually (find it on the web).
@cztomczak cztomczak changed the title Using pyenv to manage multiple Python versions on Ubuntu How to use pyenv to manage multiple Python versions on Ubuntu Sep 17, 2016
@cztomczak cztomczak changed the title How to use pyenv to manage multiple Python versions on Ubuntu How to use pyenv to manage multiple Python versions on Ubuntu/Mac Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant