Conda显示了两个版本的请求库 [英] Conda showing two versions of requests library

查看:203
本文介绍了Conda显示了两个版本的请求库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是conda的新手,看到了一些奇怪的东西,但是我实际上不知道这是否是一个问题。

I'm new to conda and seeing something strange but I don't actually know if it's a problem or not.

我目前在根环境中。在某些时候,我试图在另一个环境中安装pip,但偶然地只是运行了 pip安装请求。这似乎已将其安装在我的根环境中:

I'm currently in the root environment. At some point I was trying to install pip in another environment, but accidentally just ran pip install requests. This seems to have installed it in my root environment:

$ conda list | grep requests
requests                  2.12.4                   py36_0  
requests                  2.13.0                    <pip>

当我运行python时,pip版本似乎正在被拾取:

And it looks like the pip version is what's getting picked up when I run python:

$ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:22:00) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests; requests.__version__
'2.13.0'

我的猜测是,有两个版本的相同的包装会在以后引起头痛。然后我的假设是,最好保留非pip版本,所以我尝试了此操作:

My guess is that having two versions of the same package lying around is going to cause headaches later. Then my assumption was that I'd be better off keeping the non-pip version, so I tried this:

$ pip uninstall requests
[asks for confirmation, say yes]
$ conda list
[traceback, which I can post if helpful. Summary is:]
ModuleNotFoundError: No module named 'requests'

然后 pip安装请求使我回到第1步(具有两个版本的请求)。

Then pip install requests brings me back to square 1 (having both versions of requests).

最后,我想知道如何防止从此再次发生。根据 docs 的规定,如果我想使用pip来安装软件包在conda环境中,我应该:

Finally, I want to know how to prevent this from happening again. According to the docs, if I want to use pip to install a package in a conda environment, I should:


  1. 激活要在其中安装软件包的conda环境

  2. 运行 pip安装任何内容

  3. 它应该显示在 conda列表

  1. Activate the conda environment where you want to install the package
  2. run pip install whatever
  3. It should show up in conda list for the current environment.

但是,这对我不起作用-已安装的软件包显示在下conda list --name root 而不是当前环境。

However, this isn't working for me - the installed package shows up under conda list --name root rather than in the current environment.

因此,问题:


  1. 在我的conda中有两个要求的副本是一个问题吗?根?

  2. 如果这是一个问题,该如何解决?

  3. 如何在conda环境中使用pip?

  1. Is it a problem to have two copies of requests in my conda root?
  2. If this is a problem, how do I fix it?
  3. How do I use pip within a conda environment?


推荐答案



  1. 同时拥有两个副本是一个问题


可能是



  1. 如果这是一个问题,该如何解决?


在我的测试中, conda删除然后是 pip卸载达到目的。 (之后,您这次可以仅使用conda重新安装请求。)但是,如果出现问题,请删除 ... / lib / python3.6 / site-packages / requests-2.13.0。 dist-info

In my testing, conda remove followed by pip uninstall does the trick. (After which you can just re-install requests using only conda this time.) But if something goes wrong, remove .../lib/python3.6/site-packages/requests-2.13.0.dist-info. That seemed to work for me.

FWIW,我只能通过先使用pip 安装进行安装,然后再重新安装,从而重现双重安装

FWIW, I was only able to reproduce the double-install by installing with pip first, then installing again with conda.



  1. 如何在conda环境中使用pip?
  2. >


您在OP中的摘要正确。只需激活conda环境并像往常一样使用pip。我的经验法则是使用 conda 安装软件包(如果可用),否则请使用 pip

Your summary in the OP is correct. Just activate the conda environment and use pip as you normally would. My rule of thumb is to install packages with conda if they are available, and resort to pip otherwise.

这篇关于Conda显示了两个版本的请求库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆