如何在VScode中导入hdbscan(已安装anaconda)

huangapple go评论137阅读模式
英文:

How to import hdbscan in VScode (anaconda installed)

问题

根据现有信息,我已成功在我的conda虚拟环境中使用conda install -c conda-forge hdbscan安装了HDBSCAN包。
但是,当我尝试运行这段代码import hdbscan时,它显示如下:
(p.s. 在此之前,我键入了'python'以使其识别'import',像这样

我正在使用通过Anaconda Navigator创建的'Project'环境,并且我认为我的解释器是正确的:

另外,我必须在Anaconda创建的环境中使用'conda install'这样的命令吗(而不是pip install)?我可以使用我自己创建的带有相应解释器的虚拟环境吗?

我尝试过'pip install hdbscan',但失败了,'conda install'可以正常工作。因此,我自然期望导入hdbscan模块应该顺利进行。

英文:

1.
Based on existing information, I've successfully installed HDBSCAN package in my conda virtual environment using conda install -c conda-forge hdbscan
如何在VScode中导入hdbscan(已安装anaconda)
However, when I try to run this code import hdbscan
It says:如何在VScode中导入hdbscan(已安装anaconda)
(p.s. before that I typed in 'python' to allow it identify 'import'like this
如何在VScode中导入hdbscan(已安装anaconda)
is that correct?)

I'm using the environment created via Anaconda Navigator 'Project'
and my interpreter is the correct one I think:
如何在VScode中导入hdbscan(已安装anaconda)

2.
Also, do I have to use env created in anaconda in order to use command like 'conda install' (instead of pip install)? Can I use the virtual environment that I created by myself with the corresponding interpreter like this one?
如何在VScode中导入hdbscan(已安装anaconda)

I've tried 'pip install hdbscan' and fails, 'conda install' works. So naturally I'm expecting that importing hdbscan module should be smooth.

答案1

得分: 1

  1. 当你使用Conda安装库时,它会安装在一个虚拟环境中。看起来你在尝试导入hdbscan时没有激活这个环境。你可以使用命令conda activate来激活它。然后你可以像之前一样调用Python并导入库。

  2. 我认为你应该查看文档以获得第二部分的完整解释。简单来说,当你使用命令conda install时,它会将库安装在激活的环境中。因此,你必须使用在Anaconda中创建的环境才能使用类似'conda install'的命令。

你可以使用通过命令conda create创建的Conda环境,或者通过VSCode创建的环境。

英文:
  1. When you install the library with Conda, it is installed in a virtual environment. It seems you didn't activate the environment when trying to import hdbscan. You can activate it with the command conda activate. Then you can call python and your import as you did.

  2. I think you should look at the documentation to have a complete explanation for the second part. But a short is that, when you use the command conda install, it install the librairy in the environment that is activate. So you have to use env created in anaconda in order to use command like 'conda install'

You can use conda environment created by the command conda create or created by vscode

huangapple
  • 本文由 发表于 2023年6月12日 00:01:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76451318.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定