我正在尝试使用以下代码从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
?