I successfully installed a virtual environment in Ubuntu 22.10 (VirtualBox) by following this excellent tutorial: www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-ubuntu-22-04. Thank you, Alex. I have two follow up questions:
my_env
directory that is created by the python3 -m venv my_env
command. Is this correct? I am asking, because I am planning to create a second virtual environment, and to use a different/older version of Ptyhon. Somehow I feel I should be working from within the respective directory created by the venv
command, especially since I will have more than one environment.Thanks. I have always found the DigitalOcean tutorials comprehensive and well-written.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
You will be working form the directory that you’ve created with the
mkdir
command.For example let’s say that you have 2 projects:
project1
thencd
into it and create the venv,python3 -m venv p1_env
project2
thencd
into it and create the venv,python3 -m venv p2_env
For your second question, in order to install Python
3.9
on Ubuntu, you can use thepyenv
CLI to install specific Python versions:https://github.com/pyenv/pyenv#getting-pyenv
This will download and run the pyenv installer script. It will add the necessary configuration to your shell profile file (e.g. ~/.bashrc) to initialize pyenv on each new terminal session.
This should output the version of pyenv that you installed.
This will download and install Python 3.10.0. You can install other Python versions in the same way.
This will set the global Python version to 3.10.0. You can also set the Python version for a specific directory using the
pyenv local
command.Let me know if you have any questions!
Best,
Bobby