Sign in

Python Virtual Environments Tutorial for Beginners


Virtual Environments

$ sudo apt install python3.6-venv

Creating a Virtual Environment

$ mkdir yourproject
$ cd yourproject
import requests#Call the api 
response = requests.get('')
#Print response code
$ python -m venv example-env
yourproject/├── example-env│ ├── bin│ ├── include│ ├── lib│ ├── lib64│ └── pyvenv.cfg└──
$ source example-env/bin/activate
$(example-env) user@ubuntu:
$ pip install requests
$ python
$ deactivate

Creating and Using a Requirements File

$ pip freeze > requirements.txt
$ pip install -r requirements.txt

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