Skip to content

Instantly share code, notes, and snippets.

@scottie
Last active September 19, 2023 11:20
Show Gist options
  • Save scottie/1436121a36af9e2a2843ad879d1c92ee to your computer and use it in GitHub Desktop.
Save scottie/1436121a36af9e2a2843ad879d1c92ee to your computer and use it in GitHub Desktop.
setup_python_virtualenviroment
  1. Open a terminal window.

  2. Navigate to the directory where you want to create the virtual environment. You can use the cd command to change directories.

  3. Run the following command to create a virtual environment with Python 3:

python3 -m venv venv_name

Replace venv_name with the name you want to give to your virtual environment. For example:

python3 -m venv myenv

This command will create a directory with the specified name (e.g., myenv) in your current location, and it will set up a new Python environment within that directory.

  1. Activate the virtual environment by running the following command:
source venv_name/bin/activate

Replace venv_name with the name you used in step 3. After running this command, your terminal prompt should change to indicate that you are now working within the virtual environment.

  1. You can now install packages and work with Python as if it's a fresh Python environment. Any packages you install will be isolated within this virtual environment and won't affect your system-wide Python installation.

  2. To deactivate the virtual environment and return to your system's global Python environment, simply run:

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