351 Followers
·
Follow

Setting Up Virtual Environment

I assumed you have Python installed and want to set up a virtual environment in order to start a project. Below are ways you can get started on different platforms:

Note: myven :- virtual environment name

Windows
Open CMD
Change Directory to your project directory
> cd project_directory
> python -m venv myven
> myven\scripts\activate

Linux/MacOS
Open Terminal /Console
$ sudo apt-get install virtualenv
#creating the virtual environment
$ virtualenv myven
#You can also use a Python interpreter of your choice
$ virtualenv -p /usr/bin/python2.7 myven
$ source myven/bin/activate

Ouch! So you tried creating your venv and then you encountered this error on your terminal 👉 The path python2 (from — python=python) does not exist
Do the following:
sudo apt-get update
sudo apt install python
When done go back to creating the virtual environment!

To deactivate virtual environment
> deactivate
$ deactivate

Written by

Software Engineer / UI Designer / PSF Fellow / DSF Member / Community Builder / Wikimedian In Residence

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store