If you encounter any problems as follows, you should try to set up a personal Python(Anaconda) mirror:
- Deploy a python environment on servers that have no access to the Internet;
- Deploy a python environment which can be used directly by other users on the server;
- Internet speed or connection to cloud mirror is slow.
Just install Anaconda according to this guide.
Of course, you can download Anaconda installer archive from here.
If your server is located in China, I recommend the later one.
I’ll take the later one as example.
Create your directory for saving packages:
Create two files for downloading packages:
Save all urls you wanted to
Then, edit the
download.sh file to download all files in each directory:
Explanations of options:
conda-forge is much larger than others. Of course, you can just download specific version and packages:
Don’t forget to download
conda won’t work correctly.
Anyway, if your
download.sh are as same sa mine, you will get this tree of directory:
It’s more convenient to save all packages in one directory and just using
channel_alias for channels.
Now, you can modify the channel_alias and add channels:
If you prefer command line, you can just use
conda config --get :
If you make a mistake during adding channel, you can remove it:
By default, conda now prefers packages from a higher priority channel over any version from a lower priority channel. Therefore, you can now safely put channels at the bottom of your channel list to provide additional packages that are not in the default channels, and still be confident that these channels will not override the core package set.
So, if you want to set the order to free → main → conda-forge, you can rearrange them by terminal or edit the
.condarc file directly.
Anyway, you will get this
Content between these dividing lines are wrong according to this answer.
Let’s create a new
test to prepare for next step (Aggregation).
What about the ‘anaconda’ channel on anaconda.org at https://anaconda.org/anaconda?
The Anaconda channel on anaconda.org is an aggregated mirror of the packages in https://repo.continuum.io/pkgs/main, https://repo.continuum.io/pkgs/free, and https://repo.continuum.io/pkgs/pro. If you are using conda’s ‘defaults’ channel, you do not need the ‘anaconda’ channel.
Although you’ve downloaded packages, but if you want to install as usual like
conda install -c anaconda netcdf4, you have to aggregate
So, you should create a directory named
Then, link all files under each
Now, you can use
conda-build to generates a file
Now, you can use
conda update/install :
anaconda channel anymore, because we just have
For example, if you want to install
anaconda channel, don’t specify channel name:
If you have many packaged to install, you can create
requirements.txt and install all of them by one command.
Here’s one example of
If you’re the administrator of the server, you can use system
.condarc to set a environment for all users.
You can make conda and any number of packages available to a group of 1 or more users, while preventing these users from installing unwanted packages with conda:
- Install conda and the allowed packages, if any, in a location that is under administrator control and accessible to users.
- Create a .condarc system configuration file in the root directory of the installation. This system-level configuration file will override any user-level configuration files installed by the user.
Each user accesses the central conda installation, which reads settings from the user
.condarcconfiguration file located in their home directory. The path to the user file is the same as the root environment prefix displayed by
conda info, as shown in User configuration file below. The user
.condarcfile is limited by the system
System configuration settings are commonly used in a system
.condarcfile but may also be used in a user
.condarcfile. All user configuration settings may also be used in a system
You can just check the official document about administrator-controlled installation.
Here’s the example of my system