Python3 VENV Setup For Windows & Linux
Python3 VENV Setup For Windows & Linux
For Linux
This will create a new virtual environment in a directory named myenv.
To activate the virtual environment, use the following command:
This will activate the virtual environment and change your terminal prompt to indicate that you are now working within the virtual environment.
Note: If you are using the fish shell, the command to activate the virtual environment is slightly different. Use the following command instead:
Once you have activated the virtual environment, you can install any necessary packages using pip. For example, to install the requests package, use the following command:
To exit the virtual environment and return to your normal shell environment, use the following command:
deactivate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Windows
Create the virtual environment by running the following command:
This will create a new directory called "myenv" in your current directory, containing the files necessary to run a Python3 virtual environment.
Activate the virtual environment by running the activate script in the "Scripts" subdirectory of your virtual environment. You can do this by typing:
- Code:
sudo apt install python3.11-venv
- Code:
python3 -m venv myenv
This will create a new virtual environment in a directory named myenv.
To activate the virtual environment, use the following command:
- Code:
source myenv/bin/activate
This will activate the virtual environment and change your terminal prompt to indicate that you are now working within the virtual environment.
Note: If you are using the fish shell, the command to activate the virtual environment is slightly different. Use the following command instead:
- Code:
source myenv/bin/activate.fish
Once you have activated the virtual environment, you can install any necessary packages using pip. For example, to install the requests package, use the following command:
- Code:
pip install requests
To exit the virtual environment and return to your normal shell environment, use the following command:
deactivate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Windows
- Code:
cd C:\Users\YourUsername\Desktop\myproject
Create the virtual environment by running the following command:
- Code:
python -m venv myenv
This will create a new directory called "myenv" in your current directory, containing the files necessary to run a Python3 virtual environment.
Activate the virtual environment by running the activate script in the "Scripts" subdirectory of your virtual environment. You can do this by typing:
- Code:
myenv\Scripts\activate.bat
Last edited by jamied_uk on 30th June 2023, 11:24; edited 1 time in total
Re: Python3 VENV Setup For Windows & Linux
- Code:
python.exe -m pip install --upgrade pip
pip install -r requirements.txt
Re: Python3 VENV Setup For Windows & Linux
To use a specific python version in venv
- Code:
pip install virtualenv
- Code:
virtualenv venv --python=python3.7
- Code:
virtualenv myenv --python=C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\python.exe
myenv\Scripts\activate.bat
Similar topics
» Setup OpenCV for Face Recognition AI On Linux Using Python3
» Python3 Advanced Tutorial linux windows webserver cgi programming
» Python3 Auto-Clickers For Windows
» how to setup samba for linux config and allowing linux shares and adding users to samba commands
» openvpn setup on linux
» Python3 Advanced Tutorial linux windows webserver cgi programming
» Python3 Auto-Clickers For Windows
» how to setup samba for linux config and allowing linux shares and adding users to samba commands
» openvpn setup on linux
Permissions in this forum:
You cannot reply to topics in this forum
|
|