The steps below will walk you through creating a Python virtual environment and kernel so that it may be used in your notebooks.
If you're not already logged in, follow the steps found here. In the upper-right corner, click the New button and select Terminal.
In the Terminal, enter the command below to create a virtual environment. In this example,
myEnv is the name used for the virtual environment, but you may name this whatever you'd like.
Press return when asked to proceed. All packages needed by the virtual environment will be downloaded and installed.
source activate myEnv to activate your virtual environment. Again, you may have used a different name, so substitute as appropriate. You should now see a prompt with the name of your virtual environment in parenthesis as shown.
Now that you are in your virtual environment, you may install packages using
conda install or
pip install. For example, to install the
requests package, run:
Note: We highly recommend trying
conda install first, as it installs low level dependencies that some packages (such as tensorflow) need. If this does not work, then use
To use your virtual environment and the packages installed in it, you will need to create an environment kernel. To do this, you first need to install
ipykernel by running the following:
Now create the kernel for your environment by running:
Note: Neither the name or display-name have to be the same as your virtual environment name, but it is recommended to avoid confusion.
Navigate back to the Home tab. Make sure to first refresh the page. Next, click the New button and select the name of your kernel, which is myEnv in this example.
You can now import and use packages from your kernel. Notice the
requests package imports successfully.
Note: Please be aware that common packages you may be used to using (such as pandas) are not installed by default and you will have to explicitly install these using
conda install in your virtual environment.