User Tools

Site Tools


python3

This is an old revision of the document!


Python3

If I want Python 3.7, I have to compile it myself. Use “dnf” for RedHat based distros and “apt-get” for Debian.

RedHat based distros

sudo dnf install readline-devel  # or up-arrow won't navigate history
sudo dnf install sqlite-devel openssl-devel bzip2-devel
sudo dnf install xz-devel

Then on Fedora and CentOS…

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -xvf Python-3.7.0.tgz
cd Python-3.7.0/
./configure --prefix=/usr/local/bin/python3.7 --enable-optimizations
make
sudo make install
# sudo ln -s /usr/local/bin/python3.7/bin/python3 /usr/bin/python3

On my dev system at work, I seem to have configured a prefix like /opt/python3. Then when CentOS updates itself, it changes a symbolic link in /usr/bin/python3

  sudo rm /usr/bin/python3 && sudo ln -s /opt/python3/bin/python3 /usr/bin/python3

For OS X, brew upgrading httpie seems to upgrade to the latest Python 3, so I didn't have to do stuff.

Debian based distros

For Debian (eg., Rasbian) try the following (on raspberry pi libssl-dev isn't available):

sudo apt-get install build-essential libncursesw5-dev libreadline-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev libffi-dev
The necessary bits to build these optional modules were not found:
_bz2                  _lzma                 _ssl

On Raspbian, I put it in the default location:

cd Python-3.7.0/
./configure --enable-optimizations
make -j4
sudo make install

Modules

Sometimes I have trouble with pip3 (ImportError: cannot import name 'main' from 'pip'), so prefer to use “python 3 -m pip” instead.

sudo -H python3 -m pip install --upgrade pip
sudo -H python3 -m pip install requests
sudo -H python3 -m pip install numpy
sudo -H python3 -m pip install matplotlib
python3 -m pip install --user --upgrade httpie

Weird hack for impyla

Refers to https://stackoverflow.com/questions/43918993/python-buildpack-fatal-error-sasl-sasl-h-no-such-file-or-directory

sudo python3 -m pip install --no-deps impyla
sudo python3 -m pip install --no-deps git+https://github.com/snowch/thrift_sasl
# sudo python3 -m pip install thriftpy
python3.1538805804.txt.gz · Last modified: 2023/04/12 20:44 (external edit)