News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

mamba环境管理和安装包的细节(含conda/pip区分)

posted on 2023-05-03 20:52     read(1055)     comment(0)     like(3)     collect(0)


environmental management

Don't use conda, you can use mamba. Search for mamba or miniforge in google, go to github to download the release and install it. It is the replacement of conda, but it is much faster and the output information is richer.

mamba and pip install

You can only use mamba to install the package, or you can use mamba to switch the environment and use pip to install the package. The success rate of pip is much higher, and the speed is also very fast. It is recommended to use pip...

when you use

The difference between the two is well written.

Author: Yueta
Link: https://www.zhihu.com/question/395145313/answer/2449421755
Source: Zhihu

  • conda install xxx: The library installed in this way will be placed mambaforge/pkgsin the directory. The advantage of this is that when a library has been downloaded in a certain environment, and this library is needed in another environment, you can directly Copy the library from the pkgs directory to the new environment without having to download it repeatedly.
  • pip install xxx: There are two cases, one case is that the python in the current conda environment is installed by conda, which is different from the system, and it is not base env, then xxx will be installed in the folder (the base environment will be mambaforge/envs/current_env/lib/python3.x/site-packagesinstalled mambaforge/Lib/site-packages) , if the current conda environment uses the system python, then xxx will usually be installed into ~/.local/lib/python3.x/site-packagesthe folder
  • Of course, both can specify the installation path

这里引出一个问题:conda和pip安装同一个xxx库情况下,conda环境下python代码中import xxx时,谁安装的xxx优先级较高会被import,这个问题通过下面这条命令可以解决:

python -m site

在我的机器上,会有类似下面输出:

  1. (py3.6) [~/anaconda3/pkgs @ s64]$ python -m site
  2. sys.path = [
  3. '~/anaconda3/pkgs',
  4. '~/anaconda3/envs/py3.6/lib/python36.zip',
  5. '~/anaconda3/envs/py3.6/lib/python3.6',
  6. '~/anaconda3/envs/py3.6/lib/python3.6/lib-dynload',
  7. '~/anaconda3/envs/py3.6/lib/python3.6/site-packages',
  8. ]
  9. USER_BASE: '~/.local' (exists)
  10. USER_SITE: '~/.local/lib/python3.6/site-packages' (doesn't exist)
  11. ENABLE_USER_SITE: True

这里的USER_BASE 和USER_SITE其实就是用户自定义的启用Python脚本和依赖安装包的基础路径,从上面的输出可以看到,import xxx时,先找的是anaconda3/pkgs目录,所以conda安装的包会被import进来。

作者:HexUp
链接:https://www.zhihu.com/question/395145313/answer/1230725052
来源:知乎
 

pip是用来安装python包的,安装的是python wheel或者源代码的包。从源码安装的时候需要有编译器的支持,pip也不会去支持python语言之外的依赖项。

conda是用来安装conda package,虽然大部分conda包是python的,但它支持了不少非python语言写的依赖项,比如mkl cuda这种c c++写的包。然后,conda安装的都是编译好的二进制包,不需要你自己编译。所以,pip有时候系统环境没有某个编译器可能会失败,conda不会。这导致了conda装东西的体积一般比较大,尤其是mkl这种,动不动几百兆甚至一G多。

安装过程问题

1. opencv从conda安装,vscode代码补全会有bug,用pip就好了

2. clash代理直接开全局,可以用迅雷加速下载 。规则模式迅雷偶尔识别不到。mamba规则和全局代理都ok,但是pip一定要命令行指明代理“--proxy="http://IP:port",ip在“设置”,port在clash首页

3. I encountered a lot of problems when using the official website command to install cuda 11.7 torch from mamba:

 At the beginning, the error was reported "another program is using this file, and the process cannot be accessed". After deleting, the access to the source of nvidia/noarch timed out again. After deleting all downloaded files, it was stuck at "Looking for ['pytorch'] after manual installation. " This step.

Finally, uninstall mambaforge, and then install the failed cuda package directly by referring to this article for manual installation . All warning packages in the middle will be deleted, which solves the problem.

Under win10, conda installs the latest version of GPU version pytorch: cuda11.7, the pit encountered- FSWLY - 博客园

 In fact, conda calls the tar.bz2 downloaded for installation tarballs. When changing the system, you can copy these difficult-to-download packages and manually use "mamba install --use-local path" 



Category of website: technical article > Blog

Author:Believesinkinto

link:http://www.pythonblackhole.com/blog/article/267/f36aca5ad8a69b4e0c8d/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

3 0
collect article
collected

Comment content: (supports up to 255 characters)