Python:conda install 和pip install的区别
2022-05-13 22:32
1801 查看
pip是个安装包的软件,conda是个环境管理的工具。conda能够安装多个python解释器,pip不行。因此conda在实际开发中是主要用来隔离不同的python版本和Tensorflow&Pytorch的环境(env)的。
一般Python可分为系统自带的和在conda中安装的。我们可以用下列命令查看本机上所有可用的Python环境:
(base) orion-orion@MacBook-Pro /usr % python -m site sys.path = [ '/usr', '/Users/orion-orion/miniforge3/lib/python39.zip', '/Users/orion-orion/miniforge3/lib/python3.9', '/Users/orion-orion/miniforge3/lib/python3.9/lib-dynload', '/Users/orion-orion/miniforge3/lib/python3.9/site-packages', ] USER_BASE: '/Users/orion-orion/.local' (exists) USER_SITE: '/Users/orion-orion/.local/lib/python3.9/site-packages' (doesn't exist) ENABLE_USER_SITE: True
然后我们再说两种方式:
conda install xxx:这种方式安装的库都会放在
/Users/orion-orion/miniforge3/pkgs目录下。这样的好处是,当在某个环境下已经下载好了某个库,再在另一个环境中还需要这个库时,就可以直接从pkgs目录下将该库复制至新环境而不用重复下载。
pip install xxx:这是就要两种情况,一种情况就是此时使用的是conda中安装的python,那么xxx会被安装到
/Users/orion-orion/miniforge3/lib/python3.9/site-packages文件夹中;如果当前用的是系统的python,那么xxx会通常会被安装到
/Users/orion-orion/.local/lib/python3.9/site-packages文件夹中
下面我们来看下conda中的python环境。我们可以用命令
conda info --env来查看当前的所有conda环境:
(base) orion-orion@MacBook-Pro miniforge3 % conda info --env # conda environments: # base * /Users/orion-orion/miniforge3
这里我们只有初始的base环境,即
/Users/orion-orion/miniforge3目录,此环境中Python的安装目录为:
/Users/orion-orion/miniforge3/lib/python3.9
而该Python版本对应的包的目录为:
/Users/orion-orion/miniforge3/lib/python3.9/site-packages
可以看到,这个目录下即我们所安装的Python包:
(base) orion-orion@MacBook-Pro site-packages % ls |grep torch torch torch-1.8.0.dist-info torch_tb_profiler torch_tb_profiler-0.3.1.dist-info torchtext torchtext-0.6.0.dist-info torchvision torchvision-0.9.0a0.dist-info
参考
相关文章推荐
- pip 和 easy_install 区别,以及使用python 的虚拟环境
- pip install安装包与python install安装包的区别
- easy_install和pip区别 python
- Python虚拟环境中pip install时没有权限问题
- python安装pip和easy_install
- pip install MySQL-python 报 "EnvironmentError: mysql_config not found"
- Install Pip with Curl and Python—core—docker
- 解决pip installopencv-python命令安装opencv时出现的超时错误
- Python中easy_install 和 pip 的安装及使用
- centos安装python2.7,easy_install,pip
- pip install MySQL-python
- 解决python -m pip install --upgrade pip 升级不成功问题
- python中 pip install scrapy
- Ubuntu 14.04 install python-pip
- python 安装easy_install和pip
- pip命令提示unknown or unsupported command 'install'——python3.7安装PyInstaller经验
- python -m pip install
- 【Python】设置pip install 软件源
- pip install MySQL-python error
- [Python] easy_install 和 pip 在windows 下的安装