December 2, 2024
Overview:
This user guide outlines how to install python packages in the Windows Enclave Virtual Desktop environment. In this example, Anaconda is used to install the python packages with python 3.9.
Instructions:
Step 1: Define your analytics requirements or needs
- Which package and version do you want to install? For example: Tensorflow=2.3.0, pytorch=1.1.0; gensim; corextopic; wordcloud etc. In the Windows VDI, you will install the packages under Anaconda env and use them via Jupyter Notebook or Spyder
- Python program in use: Anaconda, a Jupyter Notebook, Spyder or something else?
Step 2: Check the version of Python
Enter and run the commands below in the Anaconda Prompt.
python --version
Step 3: Confirm that pip is available
Enter and run the command below in the Anaconda Prompt.
py -m pip --version
If pip is not installed, then first try to bootstrap it from the standard library by executing the following command in the Anaconda Prompt.
py -m ensurepip --default-pip
Step 4: Check if pip is up to date
Enter and run the commands below in the Anaconda Prompt.
py -m pip install --upgrade pip --user
Step 5: Set Up the Virtual Environment
Currently, there is a common tool for creating Python virtual environments: venv, which is available by default in Python 3.3 and later and installs pip into created virtual environments in Python 3.4 and later. Enter and run the commands below in the Anaconda Prompt.
py -m venv <DIR>
For example, venv can create my_env directory structures in the C:\ directory as follows:
py -m venv c:\my_env
Step 6: Activate the Virtual Environment
To activate the virtual environment, enter the command below and replace your given environment name with env name.
<DIR>\Scripts\activate
For example:
c:\my_env\Scripts\activate
Note: You can deactivate a virtual environment by executing the deactivate command in your terminal.
Step 7: Example of How to Install Packages from Python Package Index (PyPI)
The most common usage of pip is to install from the Python Package Index (PyPI) using a requirement specifier. A requirement specifier is composed of a project name followed by an optional version specifier. To install the latest version of the package, Tensorflow, run the following command in the Anaconda Prompt.
py -m pip install Tensorflow
To install version 2.3.0 of Tensorflow, run the following command.
py -m pip install Tensorflow==2.3.0
Additional Resources:
- Package Management
- Starting Conda on Windows, macOS, or Linux
- Managing Conda. Verify that Anaconda is installed and check that conda is updated to the current version.
- Managing environments. Create environments and move easily between them.
- Managing Python. Create an environment that has a different version of Python.
- Managing packages. Find packages available for you to install. Install packages.
Escalation:
If escalation is needed, please reach out to the Digital Service Desk to have a ticket assigned to Enclave Platform - MGB