I tried some guides that I found but nothing works. I need this virtual env for a telegram bot. I| use Visual studio code
-
Does this answer your question? [What is a virtualenv, and why should I use one?](https://stackoverflow.com/questions/41972261/what-is-a-virtualenv-and-why-should-i-use-one) – Code-Apprentice Feb 02 '22 at 19:57
-
2"I tried some guides that I found but nothing works." We can better help you solve the specific problems you encountered if you tell us what they are. [Edit] your question to include more details such as what steps you took and what happened at each step. If there is an error, I suggest googling that error to see what other people already did to solve it. – Code-Apprentice Feb 02 '22 at 19:59
3 Answers
How to install virtualenv: Install pip first
sudo apt-get install python3-pip
Then install virtualenv using pip3
sudo pip3 install virtualenv
Now create a virtual environment
virtualenv venv
you can use any name insted of venv
You can also use a Python interpreter of your choice
virtualenv -p /usr/bin/python2.7 venv
Active your virtual environment:
source venv/bin/activate
Using fish shell:
source venv/bin/activate.fish
To deactivate:
deactivate
Create virtualenv using Python3
virtualenv -p python3 myenv
Instead of using virtualenv you can use this command in Python3
python3 -m venv myenv

- 805
- 5
- 10
-
Of course, this is for if he's using Ubuntu or another Debian based based distribution. – scoochy Feb 02 '22 at 19:59
-
I created the env with the python3 -m venv myenv command that you gave me. how can I now activate it? – scorpio11 Feb 02 '22 at 20:31
-
- Install. To create a virtual environment, use the following command, where
.venv
is the name of the environment folder:
python -m venv .venv
- Activate. When you create a new virtual environment, a prompt will be displayed to allow you to select it for the workspace.
This will add the path to the Python interpreter from the new virtual environment to your workspace settings. That environment will then be used when installing packages and running code through the Python extension.
You can switch environments at any time at the bottom left corner of VS Code window or using the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P)
.

- 11
- 3
Its looks like your problem is activating the virtual environment.
source env/bin/activate
or just type activate
in your terminal.
If you are using windows try:-
env\Scripts\activate.bat

- 552
- 5
- 17