You have installed Python packages locally in one version and now wish to use them in a different version. For example, you have been using Python 3.6 but it is obsolete and will be removed soon, so you need to set up those packages for Python 3.8. There are several ways to accomplish this, depending on the package manager. In this how-to we will discuss
You will need to load the module for the newer Python version. For this example,
The Python packages are installed in a hidden location under your home directory:
y are the major and minor Python versions, respectively.
Preserve individual package versions
To preserve the versions for all individual packages, first freeze the environment into a file, say
Next, install the packages:
Use the latest versions or whichever are mutually compatible
If you have no preference on the package versions, you can remove the version requirements:
Install the packages:
-py3.8 suffix in the Anaconda module, you can create/load a conda environment that uses a different Python version. Suppose the environment name is
myenv. You can either update the existing environment or create a new one.
Update Python in the old environment
source activate myenv conda install python=3.8
Note that if you have many packages in the environment, such an update could take very long due to conda’s slow dependency resolution. Individual package versions are not preserved.
Create the new environment
It is better to create a new environment and let the dependency solver do its work from scratch:
conda create -n mynewenv python=3.8 <list of packages>
Use the syntax
<package>=<version> if you have version requirements.
conda list -n myenv to get a list of all packages in
myenv. You can use the following command to show the same list in one line without version information:
Please also visit this page for more information.