Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added a note about install upgrade pip setuptools wheel. Changed from "pip" to "python -m pip" to be consistent with the pip documentation

...

Code Block
python3 -m venv $HOME/virtenvs/projectName

...

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 -m venv $HOME/virtenvs/another-project


5. Once this environment is created, we can activate it.

...

6. The command prompt in your Terminal will change to indicate the active environment. It will look like the following:

Code Block
(projectName) hawkid@jupyter-notebook-research-hawkid:~$


7. There 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


After that, there are several ways to install packages in this virtual environment:

    a) You can specify the names of the packages that you want to install:


Code Block
pip3python -m pip install -U package1 package2 package3

...

The "-U" option upgrades all specified packages to the newest available version. Omit this option if you don't want to upgrade packages. For more options with "pip install", see the pip documentation.


    b) If you have a requirement file that contains a list of packages that you want to install, you can use:

Code Block
pip3python -m pip install -r requirements.txt

...

8. If you want to use Jupyter Notebook with this virtual environment, we can install a kernel. First, install the IPython kernel:

Code Block
pip3python -m pip install -U ipykernel


9. Now install a kernel in this environment:

...

  • Re-enter a virtual environment that was previously created

    Code Block
    source $HOME/virtenvs/projectName/bin/activate


  • Leave the virtual environment once you are finished working with it:

    Code Block
    deactivate


  • Install packages in the virtual environment:

    Code Block
    # first activate the virtual environment
    source $HOME/virtenvs/projectName/bin/activate
    
    # then install packages. The "-U" option upgrades all specified packages to the newest available version. Omit this option if you don't want to upgrade packages.
    pip3python -m pip install -U package1 package2 package3


  • List all packages installed in the virtual environment:

    Code Block
    # first activate the virtual environment
    source $HOME/virtenvs/projectName/bin/activate
    
    # list all installed packages
    python -m pip list

    See the pip documentation on "pip list" for more information.

  • Uninstall packages in the virtual environment:

    Code Block
    # first activate the virtual environment
    source $HOME/virtenvs/projectName/bin/activate
    
    # then uninstall package
    python -m pip uninstall packageName

    See the pip documentation on "pip uninstall" for more information.

Contact

If you have any questions or comments, please contact research-computing@uiowa.edu.

...