繁体   English   中英

Conda 安装与 pip 安装(导入 seaborn 包时出现问题)

[英]Conda install vs pip install(issues in importing seaborn package)

我在 jupyter notebook 中导入模块时遇到问题。 The issue is that I access the jupyter notebook through anaconda software and when i tired installing seaborn, I used the command "pip install seaborn" in cmd and the package was installed(verifed through "pip list") but when i tried importing the seborn package 在笔记本中给出了错误ModuleNotFoundError: No module named 'seaborn'我什至重新启动了 kernel、笔记本和 anacond,但问题仍然存在。 但是当我在笔记本中执行“conda list”时,package 不存在,但是在“conda install seaborn”之后,package 被安装,ZEFE90A8E604A7C840E88D03A67F6D8 被导入。 I wanted to know why this error occured as i didnt face this situation while importing numpy or pandas(for numpy or pandas only pip install was enough)

python版本:3.10.5

康达版本:4.14.0

jupyter 版本:4.10.0

警告:如果没有更多信息(例如 OP 的命令历史记录和环境设置),无法 100% 自信地回答这个问题,但最可能的解释是:

Running pip install seaborn via cmd installed seaborn in a directory that is not part of the Python path of the conda environment that the Jupyter Notebook was running in. It seems most likely you were not using a conda command prompt to pip install seaborn , but you were using a conda command prompt to pip install numpy and pandas , which is why they were installed in a directory included in the Jupyter Notebook's conda environment's Python path.

例如,用于名为<env-name>的 conda 环境的 Windows 样式文件系统中的标准 conda package 安装位置是该环境的site-packages目录C:\Users\<User>\<Conda_Distribution>\envs\<env-name>\Lib\site-packages 该目录默认在其对应环境的Python路径下。

这种关于在目录中哪里可以找到实际 conda 包的知识带有警告:除非您对 Python 导入系统和 conda 的 package 管理基础架构有专业知识,否则在 conda 中手动添加或删除目录通常是一个坏主意环境的site-packages目录。

相关警告:尽管 pip 与 conda 的互操作性在过去几年中得到了很大改善,但在您的 conda 环境中使用 pip 安装标准 ZA7F5F35426B927411FC9231B5638217 包通常不是一个好主意。 conda install存在, 你应该使用它是有原因的

有关 Python 路径是什么以及如何设置的更多详细信息,请参阅 Real Python 的此信息指南

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM