Project
Raspberry Pi Tips
Setup Python virtual environment to Raspberry Pi
Raspberry Pi 3 Model B V1.2
$ cat /etc/debian_version 9.11
1: Download pyenv
$ cd /tmp $ git clone https://github.com/pyenv/pyenv.git ~/.pyenv Cloning into '/home/pi/.pyenv'... remote: Enumerating objects: 29, done. remote: Counting objects: 100% (29/29), done. remote: Compressing objects: 100% (23/23), done. remote: Total 17972 (delta 9), reused 9 (delta 3), pack-reused 17943 Receiving objects: 100% (17972/17972), 3.55 MiB | 1.35 MiB/s, done. Resolving deltas: 100% (12236/12236), done.
2: Update pyenv
$ git pull Already up-to-date.
3: Setup pyenv (to bash)
$ echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.bashrc $ echo 'if [ -d "${PYENV_ROOT}" ]; then' >> ~/.bashrc $ echo ' export PATH=${PYENV_ROOT}/bin:$PATH' >> ~/.bashrcpi@homepi:~/.pyenv $ echo ' eval "$(pyenv init -)"' >> ~/.bashrc $ echo 'fi' >> ~/.bashrc $ exec $SHELL -l
4: Check installable python version list on pyenv
$ pyenv rehash $ pyenv install -l
5: Install python 3.7.0 (the same version for pyupdi
$ pyenv install 3.7.0 Downloading Python-3.7.0.tar.xz... -> https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz Installing Python-3.7.0... Installed Python-3.7.0 to /home/pi/.pyenv/versions/3.7.0
This command takes 15 minutes for my RaspPi.
6: Switch python version at current directory
$ cd ~/Arduino/build $ pyenv versions * system (set by /home/pi/.pyenv/version) 3.7.0 $ pyenv local 3.7.0 $ pyenv versions system * 3.7.0 (set by /home/pi/Arduino/build/.python-version)
Refs: