当前位置: 首页 > 工具软件 > Gluon Project > 使用案例 >

pip(easy_install)anaconda本地安装文件包(附gluon-cv的升级过程)

李康安
2023-12-01

pip本地安装

pip下载到本地后切换到下载目录再安装,小事,但是这样的包多了,很繁琐!

pip install piptestfile-1.1.0b0-py2.py3-none-any.whl(.whl安装包名称)

这里有个小窍门:只输入前面一部分,例如输入上图文件名中的开头字母T,然后按Tab键,后面部分会自动补全

 

anaconda本地安装

从某个地址安装

conda install -c https://conda.website.org/<package-name>        <package-name>

本地安装

conda install --offline     C:\abc-1.2.3-py35_0.tar.bz2
conda install --use-local    c:/downloads/abc-1.2.3-py35_0.tar.bz2

貌似说conda本地安装不会添加依赖(参考:https://github.com/conda/conda/issues/1884

 

附录: easy_install 和 pip的介绍

easy_install和pip都是用来下载安装Python一个公共资源库PyPI的相关资源包的,pip是easy_install的改进版,提供更好的提示信
息,删除package等功能。老版本的python中只有easy_install,没有pip。

easy_install 打包和发布 Python 包

pip 是包管理

easy_install 的安装

前提是python的环境已配置好,下载地址:https://pypi.python.org/pypi/ez_setup

下载 ez_setup.py 后,在命令 界面输入:python ez_setup.py

pip 的安装

待根据上述操作,安装好easy_install 之后,再安装pip

下载地址:https://pypi.python.org/pypi/pip

下载到桌面,解压,然后输入命令:python setup.py install ,开始安装。

 

easy_install的用法

这个工具我用的比较少,不如PIP那么频繁,举个例子,我把protobuf的egg下载到本地后,这样安装
python -m easy_install protobuf-3.6.1-py3.6-win-amd64.egg
pthon -m 的意思是run module as script (参考:python --help)

大体上的用法如下,
安装一个包
easy_install 包名
easy_install "包名 == 包的版本号"

升级一个包
easy_install -U "包名 >= 包的版本号"

 

pip 的用法

安装一个包
pip install 包名
pip install 包名 == 包的版本号

升级一个包 (如果不提供version号,升级到最新版本)
pip install --upgrade 包名 >= 包的版本号

删除一个包
pip uninstall  包名

强迫升降级安装
pip install 'package==1.0.0' --force-reinstall

配置pip3

我经常碰到找不到pip3的情况,一般,快速的解决办法是,把pip3.exe, easy_install-3.6.exe等需要用到文件直接拷贝到所在的环境目录,比如我的某个环境目录下是这样的,

D:\Anaconda3\envs\env_name_py36\Scripts
  ________
                  |---pip.exe
  ________
                  |---pip3.exe
  ________
                  |---easy_install.exe
  ________
                  |---easy_install-3.exe

也不知道总是这样直接拷贝有没有问题,总之缺什么的话也只能另外再补上安装了。

 

后记:

正常情况下,如果你能使用官网所提供的指令(https://gluon-cv.mxnet.io/install/install-more.html)一次安装成功,

pip install --upgrade gluoncv

pip会帮你把相关的依赖统统都装好,加起来主要包括:
Installing collected packages: tqdm, portalocker, Pillow, cycler, kiwisolver, matplotlib, scipy, gluoncv

注意,官网上原有的指令是

pip install --upgrade mxnet gluoncv

而实际上我不推荐和mxnet一起安装,单独安装mxnet你可以选择自己想要的版本,尤其是有gpu的情况下,版本要和驱动程序的版本一致,否则会产生相当多的问题。

 

情况不好的时候,就和我下面的方法一样,挨个自己装吧!
这主要是因为最近网络抽风严重,一个几十K的东西,费老半天装不上去,只好下载后再pip, 下面这个例子是升级gluon-cv的全过程,这时直接使用pip install --upgrade gluoncv 就别说了,根本装不上去,所以只好到这里(https://pypi.org/project/gluoncv/#files)把文件包下载下来,具体下载地址是:https://files.pythonhosted.org/packages/fa/81/37a00609cb53da3671adb106b9bc03fb1c029ad5a8db4bc668283e65703d/gluoncv-0.7.0-py2.py3-none-any.whl

或者tar包:
https://files.pythonhosted.org/packages/51/62/29fc7d2c6319a363e49b7854fb47111dba6ed0e02aa94dee5acf2ed6965b/gluoncv-0.7.0.tar.gz

然后再切换到下载目录下安装,如下

(mxnet36) H:\>cd H:\down_pipwheels
(mxnet36) H:\down_pipwheels>pip install gluoncv-0.7.0-py2.py3-none-any.whl --upgrade
Processing h:\down_pipwheels\gluoncv-0.7.0-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: matplotlib in d:\anaconda3\envs\mx36\lib\site-packages (from gluoncv==0.7.0) (3.1.1)
Collecting portalocker (from gluoncv==0.7.0)
  Downloading https://files.pythonhosted.org/packages/53/84/7b3146ec6378d28abc73ab484f09f47dfa008ad6f03f33d90a369f880e25/portalocker-1.7.0-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: numpy in d:\anaconda3\envs\mx36\lib\site-packages (from gluoncv==0.7.0) (1.16.5)
Requirement already satisfied, skipping upgrade: tqdm in d:\anaconda3\envs\mx36\lib\site-packages (from gluoncv==0.7.0) (4.36.1)
Requirement already satisfied, skipping upgrade: Pillow in d:\anaconda3\envs\mx36\lib\site-packages (from gluoncv==0.7.0) (6.2.0)
Requirement already satisfied, skipping upgrade: scipy in d:\anaconda3\envs\mx36\lib\site-packages (from gluoncv==0.7.0) (1.3.1)
Requirement already satisfied, skipping upgrade: requests in d:\anaconda3\envs\mx36\lib\site-packages (from gluoncv==0.7.0) (2.22.0)
Requirement already satisfied, skipping upgrade: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in d:\anaconda3\envs\mx36\lib\site-packages (from matplotlib->gluoncv==0.7.0) (2.4.5)
Requirement already satisfied, skipping upgrade: python-dateutil>=2.1 in d:\anaconda3\envs\mx36\lib\site-packages (from matplotlib->gluoncv==0.7.0) (2.8.1)
Requirement already satisfied, skipping upgrade: cycler>=0.10 in d:\anaconda3\envs\mx36\lib\site-packages (from matplotlib->gluoncv==0.7.0) (0.10.0)
Requirement already satisfied, skipping upgrade: kiwisolver>=1.0.1 in d:\anaconda3\envs\mx36\lib\site-packages (from matplotlib->gluoncv==0.7.0) (1.1.0)
Requirement already satisfied, skipping upgrade: pywin32!=226; platform_system == "Windows" in d:\anaconda3\envs\mx36\lib\site-packages (from portalocker->gluoncv==0.7.0) (223)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in d:\anaconda3\envs\mx36\lib\site-packages (from requests->gluoncv==0.7.0) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in d:\anaconda3\envs\mx36\lib\site-packages (from requests->gluoncv==0.7.0) (2.8)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in d:\anaconda3\envs\mx36\lib\site-packages (from requests->gluoncv==0.7.0) (2020.4.5.1)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in d:\anaconda3\envs\mx36\lib\site-packages (from requests->gluoncv==0.7.0) (1.24.2)
Requirement already satisfied, skipping upgrade: six>=1.5 in d:\anaconda3\envs\mx36\lib\site-packages (from python-dateutil>=2.1->matplotlib->gluoncv==0.7.0) (1.12.0)
Requirement already satisfied, skipping upgrade: setuptools in d:\anaconda3\envs\mx36\lib\site-packages (from kiwisolver>=1.0.1->matplotlib->gluoncv==0.7.0) (41.4.0)
Installing collected packages: portalocker, gluoncv
  Found existing installation: gluoncv 0.5.0
    Uninstalling gluoncv-0.5.0:
      Successfully uninstalled gluoncv-0.5.0
Successfully installed gluoncv-0.7.0 portalocker-1.7.0
 

 类似资料: