Last active
August 14, 2017 06:51
-
-
Save verdimrc/b7de5e0e1e0a88e284e318cdf88e1268 to your computer and use it in GitHub Desktop.
Install py36 on Ubuntu 17.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ubuntu 17.04, 16.10 | |
# Download Miniconda3*.sh from miniconda website, then follow the installation | |
# instruction. | |
# NOTE: | |
# - do NOT sudo pip install conda, as this will not work with the latest conda! | |
# - we choose NOT to prepend miniconda3 to PATH. | |
~/miniconda3/bin/conda update --all | |
# Install anaconda cli. | |
# NOTE: to install the whole PyData stuffs, install the anaconda package. | |
~/miniconda3/bin/conda install anaconda-client | |
~/miniconda3/bin/conda create --name py36 python=3.6 ipykernel ipython | |
# Update root & py36 environments from outside of the environments. | |
for i in root py36; do ~/miniconda3/bin/conda upgrade -n $i --all; done | |
# Can put the alias to .bashrc | |
alias source_activate='source /home/verdi/miniconda3/bin/activate' | |
source_activate py36 | |
python --version # Make sure it emits 3.6.x | |
# Create a Jupyter kernel which can be invoked from conda's root environment. | |
# Installed kernelspec py36 in /home/verdi/.local/share/jupyter/kernels/py36. | |
# See kernel.json for the actual kernel invocation. | |
python -m ipykernel install --user --name py36 --display-name 'Python 3.6' | |
# Install ipdb from community channels | |
anaconda search -t conda ipdb # Show channels and arch | |
#conda install -c anjos ipdb #linux32 | |
conda install -c conda-forge ipdb #linux64 | |
source deactivate | |
# Start jupyter on conda's root environment (Ubuntu's python). | |
# Jupyter should have a new kernel for Python 3.6. | |
jupyter notebook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu 16.10. | |
# Manual install is not recommended. Prefer conda instead! | |
# NOTE: break /usr/bin/pip3 & /usr/bin/local/bin/{pip3,pip3.5}. | |
# Need to patch by importing pip.main twice, that is by changing: | |
# from pip import main | |
# to | |
# try: | |
# from pip import main | |
# except: | |
# from pip import main | |
# NOTE: build args from Ubuntu's stock python3.6 (beta1) | |
python3.6 -c 'import sysconfig; print(sysconfig.get_config_var("CONFIG_ARGS"))' | |
export CC=x86_64-linux-gnu-gcc | |
# We don't build debug | |
#export CFLAGS='-g -fdebug-prefix-map=/build/python3.6-mTGOPz/python3.6-3.6.0~b2=. -fstack-protector-strong -Wformat -Werror=format-security' | |
export CFLAGS='-fstack-protector-strong -Wformat -Werror=format-security' | |
export LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro' | |
export CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' | |
# NOTE: --with-system-ffi is default with python3.6, thus no need to specify | |
sudo apt install libmpdec-dev libgdbm-dev libffi-dev libexpat1-dev | |
./configure --enable-shared --enable-ipv6 --enable-loadable-sqlite-extensions --with-dbmliborder=bdb:gdbm --with-computed-gotos --without-ensurepip --with-system-expat --with-system-libmpdec --with-fpectl | |
make | |
sudo make altinstall # altinstall install python3.6 binary, leaving python3 intact | |
# Backup existing pip binaries in /usr/bin & /usr/local/bin | |
sudo python3.6 get-pip.py | |
mv /usr/local/bin/pip3{,.6} # Rename new pip3 to pip3.6 | |
# Restore old pip binaries (2.7, 3.5) | |
# If pip3 is broken, do 'from pip import main' twice (in a try-except block) | |
sudo pip3.6 install --upgrade | |
# Backup old ipython binaries in /usr/bin & /usr/local/bin | |
sudo pip3.6 install ipython zmq ipykernel | |
# Rename new ipython3 to ipython3.6 | |
# Restore old ipython binaries (2.7, 3.5) | |
# Test kernel | |
python3.6 -c "import ipykernel" | |
python3.6 -m ipykernel install --user --name python3.6 --display-name 'Python 3.6' | |
#Installed kernelspec python3.6 in /home/verdi/.local/share/jupyter/kernels/python3.6 | |
cat /home/verdi/.local/share/jupyter/kernels/python3.6/kernel.json | |
{ | |
"argv": [ | |
"/usr/local/bin/python3.6", | |
"-m", | |
"ipykernel", | |
"-f", | |
"{connection_file}" | |
], | |
"display_name": "Python 3.6", | |
"language": "python" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment