Install Multiple Python Versions on Raspberry Pi

preview_player
Показать описание
This video teaches you how to install multiple python versions on your Raspberry Pi using pyenv. Let me know if you have any questions or requests for future tutorials!

I may earn commission if you purchase from the links above

INSTRUCTIONS and TIMESTAMPS:
0:00 Intro

0:32 (0) Access the terminal

0:58 (1) Run the easy installer

1:10 (2) Add pyenv to .bashrc:
Edit the .bashrc with the command
sudo nano ~/.bashrc
Add the following three lines to the botton of the .bashrc file:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

1:45 (3) Restart the terminal
exec $SHELL

1:54 (4) Install system packages
sudo apt-get install --yes libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libgdbm-dev lzma lzma-dev tcl-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev wget curl make build-essential openssl

2:11 (5) Update pyenv
pyenv update

2:22 (6) Install python versions
pyenv install --list
pyenv install ~~Your python version~~

2:59 (7) Set python verion
pyenv local 3.7.12
or
pyenv shell 3.7.12
or
pyenv global 3.7.12

4:39 (8) To uninstall (in case you followed along and changed your mind)vi
rm -fr ~/.pyenv
Remove lines from .bashrc (sudo nano ~/.bashrc)

4:45 Outro

Рекомендации по теме
Комментарии
Автор

I love you man, I legit just lost a whole day trying to get a virtual environment running for a specific python version. After so many methods and attempts, this was such a simple implementation. I can finally go to sleep

way-out
Автор

This video was so helpful for my work.Thank you much Sam ! Appreciate it :)

keremmor
Автор

Hi sam!, great video, but i had a problem, how do i install library on the virtual environment? for example i want to install opencv in python 3.9.6, i've try to 'sudo apt-get install python3-opencv' after i'm inside the virtual environtment, but it didn't work

LifeofAryaElRumy
Автор

Nicely done! Greatly appreciate the instructions

hiramkuykendall
Автор

Thanks, great explanation ! I just can't change the version for my virtual environment. I followed the steps in the same venv folder but can't uninstall python 3.11 (it was installed by default) and i can't impose 3.8 that I need.
Thank you for you time.

eyaouerghemmi
Автор

It seems using pyenv global doesn't apply to a virtualenv I have created. I've tried doing different things including the eval "$(pyenv init -)" command and saving it to the bashrc file, but the virtualenv always defaults back to 3.9 when activating it. I've also looked into using pyenv virtualenv, but that doesn't seem to work in my case. Is there a simple way to set the pyenv in the virtualenv and have it remain that way?

jacobfredrickson
Автор

when installing the long list of system packages i get lots of errors saying `sudo apt fails to fetch ...` what can be the reason? infact because of these not getting installed, i am unable to use pyenv at all

stlo
Автор

Hi. I need to use GPS module code in thonny which uses python 2.7.9, but my other module codes in thonny use 3.7.3 can you tell me a solution for this please?

_RamjiG
Автор

Hello, I want to ask. The default python on my previous raspberry was 3.9, and I installed python globally 3.7 as in this video because there is a need. But when I want to run my python program through Thonny Python IDE and use python 3.7, all libraries are not listed (like picamera etc.), when I want to download the required library it says "library already exists", but can only be used when I use python 3.9 in Thonny IDE... How do I install/access those libraries in python 3.7?
Thank You

dquin
Автор

hello
i have watched your video about pyenv
i installed python 3.6.5 on raspberry pi 4 and globaled it instead of 3.9
while i am creating virtualenv on pycharm
it is asking to choose base interpreter
which file do i choose?

tariqnajjar
Автор

Bro if I type pyenv install 3.7.12 it shows downloading few lines come and it freezes at line showing patching file config and doesn't move forward can you help me?

shreyasnelgikar
Автор

How to run a script in env on reboot...

sarveshrodi
Автор

hi there thanx for you great tutoriel . i followed all the steps without any error but when i to switch to 3.7.12 i chekc the version of the python and it still the 3.9 !!
pyenv local 3.7.12 dont give any error .. do you have any idea why .?? thanx

NaturallyGlowDIY
Автор

Would this work with Bullseye Debian on the Raspberry Pi?

DaSmokeDaddy
Автор

On my end i got stuck installing python 3.11.1 on my zero and zero 2, the solution was increasing the swap space to about 512 MB or 1024 MB with the following command: sudo nano /etc/dphys-swapfile and then changing the 100 MB Line

voltieee
Автор

My rasbian OS python -V is 3.7.3 and I installed python3.9.2 through pyenv but when I try run openCV example code, I have a error like this

Original error was: version `GLIBC_2.29' not found (required by

웅-ee
Автор

why is this giving this error
bash: /home/pi/.bashrc: line 125: syntax error: unexpected end of file

when I save and exit the following command
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

sunimaliattanayake
visit shbcf.ru