如何从环境中正确删除conda包装?

我正在尝试使用以下代码从conda环境“ testenv”中删除numpy:

import subprocess
res = subprocess.run("conda remove -n testenv numpy --yes",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
print(res.returncode)

以上代码已成功完成,并将0打印为res.returncode

但是,当我尝试如下测试numpy软件包的移除时:

coda activate testenv
python
import numpy

我能够导入numpy,这没有错误,例如未找到软件包。 但是,当我尝试使用numpy软件包时,如下所示:

print(numpy.version.version)

我收到以下错误:

Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
AttributeError: module 'numpy' has no attribute 'version'

我也尝试过使用numpy.arrange(),但它给了我类似的错误,如下所示:

>>> xy = numpy.arrange(20)
Traceback (most recent call last):
  File "<stdin>",in <module>
AttributeError: module 'numpy' has no attribute 'arrange'

是什么意思? numpy是否已从我的testenv环境中完全删除?如果是这样,那我为什么可以import numpy

miaojia628 回答:如何从环境中正确删除conda包装?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3168555.html

大家都在问