在 PyCharm 中无法导入安装在 Anaconda 中的包可能是由于以下原因:
conda
或 pip
安装缺失的包。以下是详细的解决步骤:
File
-> Settings
(Windows/Linux)或 PyCharm
-> Preferences
(macOS)。Project: <your_project_name>
-> Python Interpreter
。Add...
,然后选择 Anaconda 环境中的 Python 解释器。Add Python Interpreter
对话框中,选择 Conda Environment
。Existing environment
,然后在 Interpreter
字段中选择 Anaconda 环境中的 Python 解释器路径(通常位于 ~/anaconda3/bin/python
或 ~/opt/anaconda3/bin/python
)。OK
完成配置。conda
或 pip
安装缺失的包。例如:conda install package_name
或
pip install package_name
有时,重启 PyCharm 可以解决一些缓存或配置相关的问题。
File
-> Invalidate Caches / Restart
)。领取专属 10元无门槛券
手把手带您无忧上云