Skip to content

Instantly share code, notes, and snippets.

@umairsd
Last active February 3, 2019 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umairsd/c8a00e50b2fd423c26764ed6bd4b3f75 to your computer and use it in GitHub Desktop.
Save umairsd/c8a00e50b2fd423c26764ed6bd4b3f75 to your computer and use it in GitHub Desktop.
Commands and tricks about Python.

Virtual Environments

Creating a virtual environment (by default, this will not include any of existing site packages):

# Python 3.6 and above
$ python3 -m venv ~/.virtualenv/<env-name>

In order to use this environment’s packages/resources in isolation, you need to “activate” it. To do this, just run the following:

$ source ~/.virtualenv/<env-name>/bin/activate
(env-name) $

To go back to system:

(env-name) $ deactivate

Jupyter

Once a virtual environment has been activated, install packages via

$ pip install <package-name>

To start jupyter (after activating the virtual environment):

$ jupyter notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment