模块安装在 Conda 上,但在 Spyder (Python IDE) 中导入时出错

2022-01-10 00:00:00 python spyder anaconda

问题描述

我最近在我的 Conda 中安装了 pybedtools环境,使用他们提到的命令 -

I recently installed pybedtools in my Conda environment, using the command they mentioned -

conda install -c bioconda pybedtools

但是当我在这个环境中激活 spyder 并尝试运行 import pybedtools 它给了我错误-

But then when I activated spyder in this environment, and tried to run import pybedtools it gave me the error-

Modulenotfounderror: no module named 'pybedtools'

我回去尝试使用 pip 的模块进行安装(pip install pybedtools)但它说我已经有了它 -

I went back and tried to install using the module using pip too (pip install pybedtools) but it said that I already had it -

要求已经满足:/anaconda3/envs/env1/lib/python3.5/site-packages 中的 pybedtools已满足要求:.​​/anaconda3/envs/env1/lib/python3.5/site-packages 中的六个(来自 pybedtools)

所以,我无法理解模块是如何安装的,但 Spyder 不允许我导入它.我以前从未遇到过 Anaconda 的这个问题.任何帮助都会很棒!

So, I am unable to understand how it is that the module is installed yet Spyder does not allow me to import it. I have never faced this issue with Anaconda before. Any help would be great!


解决方案

这是我解决问题的方法 -

Here is how I was able to solve the issue -

  1. 激活 root 环境.这可以通过 Windows 中的 activate root 和 Ubuntu/Mac 中的 source activate root 来完成
  2. 在此处安装上述软件包.这可以使用您在以前的环境中安装软件包时使用的相同命令来完成
  3. 回到原来的环境.现在问题将得到解决.
  1. activate the root environment. This can be done by activate root in Windows and source activate root in Ubuntu/Mac
  2. install the said package here. This can be done using the same command that you used to install the package in your previous environment
  3. Go back to your original environment. The problem will now be resolved.

不过,我很想知道为什么这种方法有效!

I would love to know, though, why this method works!

相关文章