Make sure you have
gcc
installed, e.g.:$ xcode-select --install # OS X $ sudo apt-get install build-essential # Debian, Ubuntu, Mint, etc. $ sudo yum group install "Development Tools" # RedHat, CentOS
Install pyenv
- If you're using homebrew or linuxbrew, follow the homebrew installation instructions
- If you're not using homebrew, you probably should be
- If you really insist on not using homebrew, follow the basic installation instructions
Install the latest stable version of Python:
$ pyenv install 3.5.0 Downloading Python-3.5.0.tgz... -> https://yyuu.github.io/pythons/584e3d5a02692ca52fce505e68ecd77248a6f2c99adf9db144a39087336b0fe0 Installing Python-3.5.0... Installed Python-3.5.0 to ~/.pyenv/versions/3.5.0
Set your global Python installation:
$ pyenv global 3.5.0
Download the installer from https://www.python.org/downloads/release/python-350/
Double click the installer to run it
Make sure
python
is in your path (usually not needed on OS X and Linux systems):C:\>set PATH=C:\Program Files\Python 3.5;%PATH% # Windows C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib # Windows
Make sure you have pip:
$ python -m ensurepip Ignoring indexes: https://pypi.python.org/simple Requirement already satisfied (use --upgrade to upgrade): setuptools in ~/.pyenv/versions/3.5.0/lib/python3.5/site-packages Requirement already satisfied (use --upgrade to upgrade): pip in ~/.pyenv/versions/3.5.0/lib/python3.5/site-packages
Create a virtual environment (homework: check out virtualenv and virtualenvwrapper):
$ pyvenv venv
Activate your virtual environment:
$ source venv
Install a package:
$ python -m pip install requests Collecting requests Using cached requests-2.8.1-py2.py3-none-any.whl Installing collected packages: requests Successfully installed requests-2.8.1
Verify that everything's working properly:
$ python Python 3.5.0 (default, Dec 1 2015, 19:42:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> requests.__version__ '2.8.1'
Embrace the Python philosophy:
>>> import this