deptlab:python_virtual_env
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
deptlab:python_virtual_env [2021/10/21 21:34] – [Using Virtual Environments] localadmin | deptlab:python_virtual_env [2024/09/17 17:18] (current) – [Using Virtual Environments] localadmin | ||
---|---|---|---|
Line 35: | Line 35: | ||
Create a new virtual environment inside the directory: | Create a new virtual environment inside the directory: | ||
- | python3 -m venv project_1_env | + | '' |
**Note:** By default, this will not include any of your existing site packages. | **Note:** By default, this will not include any of your existing site packages. | ||
Line 72: | Line 72: | ||
| | ||
Notice how your prompt is now prefixed with the name of your environment ('' | Notice how your prompt is now prefixed with the name of your environment ('' | ||
+ | |||
+ | Now you can use pip to install packages (large packages may take a while to install). | ||
To go back to the “system” context, execute a deactivate: | To go back to the “system” context, execute a deactivate: | ||
Line 80: | Line 82: | ||
Now your shell session is back to normal, and the python command refers to the global Python install. Remember to do this whenever you’re done using a specific virtual environment. | Now your shell session is back to normal, and the python command refers to the global Python install. Remember to do this whenever you’re done using a specific virtual environment. | ||
- | ===== Using a Python3 IDE with Virtual | + | Using Virtual |
- | ==== Spyder ==== | + | **Be sure to cleanup/ |
+ | |||
+ | ===== Tips for Using a Python3 IDE with Virtual Environments ===== | ||
+ | |||
+ | ==== Using Spyder in the 244 Lab ==== | ||
+ | - Activate (start) your virtual environment. | ||
+ | - Run spyder | ||
+ | - Go to Tools --> preferences --> python Interpreter and select the python file from the virtual env you want to link to Spyder ex : / | ||
+ | |||
+ | ==== Preferred Method on Research Computers: | ||
To use Spyder. | To use Spyder. | ||
- Activate (start) your virtual environment. | - Activate (start) your virtual environment. | ||
+ | - Install the needed packages with pip | ||
- Install Spyder into your environment using pip install spyder. | - Install Spyder into your environment using pip install spyder. | ||
- Then start spyder from the environment command line with the command spyder. | - Then start spyder from the environment command line with the command spyder. | ||
+ | ==== Spyder Method 2 (Doesn' | ||
+ | |||
+ | - Activate (start) your virtual environment. | ||
+ | - Run spyder from the environment (after source activate) | ||
+ | - Go to Tools --> preferences --> python Interpreter and select the python file from the env you want to link to spyder ex : / | ||
+ | |||
+ | |||
+ | |
deptlab/python_virtual_env.1634852049.txt.gz · Last modified: by localadmin