在离线环境下使用Python编程时,我喜欢使用Anaconda,节省了安装各种包的时间。不过也有Anaconda内置包的版本太低不能满足要求的时候,此时需要安装更高版本的包,可是在离线环境下直接使用源代码安装时,虽然可以成功安装,但是输入命令
conda list
查看安装包的版本时,这个包仍然显示是之前的版本。
此时可以将conda内置的包(例如xlrd)删除,如果直接使用
conda remove xlrd
提示:
(base) C:Usersjupiter>conda remove xlrd
Collecting package metadata (repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/repodata.json>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.
'https://repo.anaconda.com/pkgs/main/win-64'
如果加上–offline,提示要么取消,要么删除一些依赖它的包,这是我们不想要的。
(base) C:Usersjupiter>conda remove xlrd --offline
Collecting package metadata (repodata.json): done
Solving environment:
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency: - defaults/win-64::python==3.7.6=h60c2a47_2
- defaults/win-64::pywin32==227=py37he774522_1
- defaults/win-64::menuinst==1.4.16=py37he774522_0
- defaults/win-64::alabaster==0.7.12=py37_0
- 此处省略100行
- defaults/noarch::seaborn==0.10.0=py_0
- defaults/win-64::statsmodels==0.11.0=py37he774522_0
done
## Package Plan ## environment location: C:Usersjupiteranaconda3 removed specs:
- xlrd
The following NEW packages will be INSTALLED: importlib_metadata pkgs/main/win-64::importlib_metadata-1.5.0-py37_0
setuptools pkgs/main/win-64::setuptools-45.2.0-py37_0The following packages will be REMOVED: anaconda-2020.02-py37_0
xlrd-1.2.0-py37_0
Proceed ([y]/n)?
终极方法是需要添加conda命令的两个参数force 和 offline
这里以urllib3为例:
conda remove urllib3 --force --offline
其含义可以参考官 的解释(
https://docs.conda.io/projects/conda/en/latest/commands/remove.html)
–force-remove, –force
Forces removal of a package without removing packages that depend on it. Using this option will usually leave your environment in a broken and inconsistent state.
–offline
Offline mode. Don’t connect to the Internet.
声明:本站部分文章内容及图片转载于互联 、内容不代表本站观点,如有内容涉及侵权,请您立即联系本站处理,非常感谢!