Creating Python Virtual Environment in Windows
In the terminal of your python IDE or windows PowerShell, enter the command to install virtual environment.
pip install virtualenv
Now you can check whether the environment is successfully installed and also check its version
virtualenv --version
Now create a virtual environment with your chosen name.
virtualenv yourvirtenvname
Now activate your virtual environment.
.\yourvirtenvname\Scripts\activate
You can enter python by entering;
python
And exit python by entering;
exit()
Install packages in your virtual environment by using;
pip install packagename
To install a specific version of a package;
pip install packagename==1.1.1
To check the version of your installed package;
print(packagename.__version__)
To see what packages are installed in the environment;
pip freeze
To come out of the environment, enter
deactivate
To export all the installed packages (in a virtual environment) names along with their versions in a text file;
pip freeze > requirements.txt
Then to install all those packages in your environment in one go;
pip install -r requirements.txt
Comments
Post a Comment
Write something to CodeWithAbdur!