英文:
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
However, when I try to run this code import hdbscan
It says:
(p.s. before that I typed in 'python' to allow it identify 'import'like this
is that correct?)
I'm using the environment created via Anaconda Navigator 'Project'
and my interpreter is the correct one I think:
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?
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
-
当你使用Conda安装库时,它会安装在一个虚拟环境中。看起来你在尝试导入hdbscan时没有激活这个环境。你可以使用命令
conda activate
来激活它。然后你可以像之前一样调用Python并导入库。 -
我认为你应该查看文档以获得第二部分的完整解释。简单来说,当你使用命令
conda install
时,它会将库安装在激活的环境中。因此,你必须使用在Anaconda中创建的环境才能使用类似'conda install'的命令。
你可以使用通过命令conda create
创建的Conda环境,或者通过VSCode创建的环境。
英文:
-
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. -
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论