Due to some unavoidable factors, the official Python packages are sometimes inaccessible or have network instability in China. conda source also has the problem of network link failure. To solve this problem, here are some configuration methods to sort out.
Pip vs. Conda
Dependency checking
- pip: does not always show the required additional dependencies. When installing a package, it may simply ignore the dependencies and install them, only indicating errors in the results.
- conda: Lists additional required dependencies. The dependencies are automatically installed when the package is installed. You can easily switch between different versions of a package.
Environment management
- pip: It is difficult to maintain multiple environments.
- conda: It is easier to switch between environments, and environment management is simpler.
Impact on the system’s own Python
- pip: Updating/rewinding versions/uninstalling packages in system-installed Python will affect other programs.
- conda: It will not affect the system’s own Python.
Applicable languages
- pip: Only applies to Python.
- conda: works with Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, FORTRAN.
Python pip source modifications
Common pip sources.
- https://mirrors.cloud.tencent.com/pypi/simple/
- https://mirrors.aliyun.com/pypi/simple/
- https://pypi.doubanio.com/simple/
- https://pypi.tuna.tsinghua.edu.cn/simple/
- https://pypi.mirrors.ustc.edu.cn/simple/
Temporary use : Add the -i parameter to specify the pip source when using pip
|
|
Permanent modification :.
- Windows: create pip directory under user folder and create in file (%HOMEPATH%\pip\pip.ini) under pip directory
- Linux/MAC OS: path and file name in: ~/.pip/pip.conf (if you want it to take effect globally, the file can be placed in /etc/pip.conf)
Write the following in the file (index-url can be replaced by the pip source you want to use)
According to the Anaconda software source, Anaconda and Miniconda are trademarks of Anaconda, Inc. and any unauthorized public mirroring is not permitted. For its part, Anaconda, Inc. has agreed to open mirroring privileges to educational and research institutions on the condition that traffic information is provided.
The following is a compilation of available conda sources.
- Tsinghua University mirror: https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
- Shanghai Jiaotong University mirror: https://mirrors.sjtug.sjtu.edu.cn/docs/anaconda
modify configuration file
-
Generate the accompanying configuration file by the command: conda config -set show_channel_urls yes
-
Modify the generated directory configuration file .condarc
- Windows is
"%HOMEPATH%\.condarc"
- Linux/MAC OS is
"~/.condarc"
Recommended configuration content.
|
|
If there are still problems with the network, add a proxy at
- Run conda clean -i to clear the index cache and ensure that the index provided by the mirror site is used.
Command Line Direct Configuration
Enter the following command directly from the command line.
|
|
If a Conda HTTP Error is returned, you need to remove the third-party mirror link and revert to the default settings:.
Add channels for r, conda-forge, bioconda.