...
1. First, create an IDAS instance with Python. If you are a student in a class that uses Python in IDAS, follow the instructions here to access your class instance.
2. In the top right corner of your IDAS home page, click New.3. Click Terminal in order to JupyterLab, click the "Terminal" tile under "Other" to start a Terminal session.
4. Create 3. In Terminal, create a virtual environment called "projectName" inside the directory "virtenvs". This will create the "virtenvs" directory if it doesn’t exist.
...
a) Note: You will probably have several virtual environments for unrelated projects, so we created the "virtenvs" directory to organize them. You can create another (separate) virtual environment in the future like so: python3
python3 -m venv $HOME/virtenvs/another-project
54. Once this environment is created, we can activate it.
Code Block |
---|
source $HOME/virtenvs/projectName/bin/activate |
65. The command prompt in your Terminal will change to indicate the active environment. It will look like the following:
Code Block |
---|
(projectName) hawkid@jupyter-notebookhawkid@idas-research-hawkid:~$ |
76. Before installing packages in this virtual environment, it's helpful to ensure "pip", "setuptools", and "wheel" are up to date:
Code Block |
---|
python -m pip install -U pip setuptools wheel |
7. After that, there are several ways to install packages in this virtual environment:
...
Code Block |
---|
python -m pip install -r requirements.txt |
8. If you want to use Jupyter Notebook JupyterLab with this virtual environment, we can install a kernel. First, install the IPython kernel:
...
The value for "--name" is used by Jupyter internally. Any existing kernel with the same "--name" value will be overwritten. The The "--display-name" will be displayed in the Notebook menu in the Jupyter Hub tree JupyterLab page.
10. Go back to the Jupyter Hub tree page. Press F5 to reload it. Under New / NotebookJupyterLab Launcher page by pressing Ctrl+Shift+L (Windows) or Cmd+Shift+L (Mac). Under "Notebook", a new option for your kernel will now be available. In this example screenshot, the "Python 3.8Project Vis" kernel was just installed and now became available to use.
Click on that new option will to start a notebook using . In that notebook, you can use the packages that you installed in the Python virtual environment you just created.
Other useful commands to manage your Python virtual environments
...