##Instructions
- Install the dependencies from the top of this page: https://github.com/yyuu/pyenv/wiki/Common-build-problems
$ git clone git://github.com/yyuu/pyenv.git ~/.pyenv
pyenv allows you to manage Python (and pip
, etc) versions easily.
3. $ echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
(Assuming you're using bash
)
4. $ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
5. $ source ~/.bashrc
6. To install a particular version of Python to your machine:
$ pyenv install 3.4.2
(for example)
$ pyenv rehash
- this make the new version visible to pyenv
7. To choose the version of Python you want to use, follow this guide: https://github.com/yyuu/pyenv#choosing-the-python-version
Long story short, $ pyenv global $VERSION
sets the Python version you use across the board, while $ pyenv local $VERSION
sets the Python version for the current directory and its subdirectories. Once you've done that, $ python --version
should display the version you chose.
8. $ sudo pip install virtualenv virtualenvwrapper
9. $ echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc
10. $ echo 'source /usr/bin/virtualenvwrapper.sh' >> ~/.bashrc
You might run into some trouble with this line (I did at some point). If you do, try to find another file on your computer called virtualenvwrapper.sh
and point to that instead.
11. $source ~/.bashrc
12. To create a virtual environment:
$ mkvirtualenv virtual_environment_name
If you want to use a specific version of python in your virtual environment:
$ mkvirtualenv virtual_environment_name --python=/path/to/python
13. Now you can enter this virtual environment with $ workon virtual_environment_name
(tab autocompletion works!), exit it with $ deactivate
, or delete it with $ rmvirtualenv virtual_environment_name
.
14. Within your virtual environment, you can use pip
to install whatever you need. Try $ pip install ipython
- you should be able to get IPython to work with your virtual environment without much fuss.
Mostly taken from my own experience and this post: http://unix.stackexchange.com/a/83721
You can install pyenv
and virtualenvwrapper
from the Arch repositories to avoid messing with your .bashrc
or sudo pip
.
If you feel like building Python 3 from source (thanks Denis):
- Download whichever version of Python you want (e.g., https://www.python.org/downloads/release/python-342/)
$ ./configure --prefix=/opt/python3
$ make && sudo make install
- The resulting /opt/python3/bin/ folder contains the python3 interpreter, pip3, and pyvenv3.
No, the instructions are not convenient. The resulting environment is convenient.