How to do it...

Let's now suppose that we have a legacy package that depends on an earlier version of NumPy. For example, let's assume we need version 1.7 of NumPy. We can check what versions of NumPy are available in the Anaconda repository with the following command:

conda search numpy

Running this command will produce a long list, in which we find the following information:

...  
1.7.1 py33_0 defaults
...
1.7.1 py33_2 defaults
...

conda shows several available packages of NumPy, some of them compatible with Python 3. Let's now create an environment that has the older version of NumPy installed. Start by creating the new environment with the following command:

conda create --name numpy17 python=3 numpy=1.7

Notice that we specify the required versions for both Python and NumPy. conda will then display the following information about the environment to be created:

The following NEW packages will be INSTALLED:
numpy: 1.7.1-py33_2
openssl: 1.0.1k-1
pip: 8.0.3-py33_0
python: 3.3.5-3
readline: 6.2-2
...

Notice that conda will downgrade the version of Python in the new environment. conda packages are carefully designed to prevent incompatibilities. Go ahead and accept the changes to start the installation.

When the installation is complete, activate the new package. On Linux and macOS, we do this with with the following command:

source activate numpy17

On Windows, use the following command to activate the environment:

activate numpy17

After the environment is activated, we can install any packages that require version 1.7 of NumPy.

When we have finished working on the project, we need to deactivate the environment. On Linux and macOS, we use the following command:

source deactivate numpy17

On Windows, the command to deactivate an environment is as follows:

deactivate numpy17
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset