在命令行上安装了一个包,可以通过命令行导入它。在 jupyter 笔记本中导入时收到 ModuleNotFoundError
Installed a package on command line and can import it via command line. Receive ModuleNotFoundError when importing in jupyter notebook
我在我的终端上安装了 python 软件包 lifelines
。 windows 终端是我的首选终端,有一个我经常使用的 powershell 和 anaconda 终端。
我尝试使用文档中提供的命令安装包:
pip install lifelines
和
conda install -c conda-forge lifelines
两次安装都被标记为成功。当我在终端内 运行 Python 时,我可以毫无问题地导入生命线包。然而,当我将它导入到 jupyter notebook 上时,它会产生一个 ModuleNotFoundError.
我使用的基础环境在使用Anaconda Navigator验证其内容时不包含lifelines包。
Anaconda Powershell 上的 jupyter notebooks 运行,环境和包也是如此。
在Windows 电源shell 上安装将永远无法工作。 运行 Anaconda shell 中的 conda install -c conda-forge lifelines
解决了这个问题。
如此愚蠢,却如此耗时,值得分享。
我遇到了这样的问题,python3 -m pip install <package_name>
帮我解决了。将 python -m pip install <package_name>
用于 Python2。
我在我的终端上安装了 python 软件包 lifelines
。 windows 终端是我的首选终端,有一个我经常使用的 powershell 和 anaconda 终端。
我尝试使用文档中提供的命令安装包:
pip install lifelines
和
conda install -c conda-forge lifelines
两次安装都被标记为成功。当我在终端内 运行 Python 时,我可以毫无问题地导入生命线包。然而,当我将它导入到 jupyter notebook 上时,它会产生一个 ModuleNotFoundError.
我使用的基础环境在使用Anaconda Navigator验证其内容时不包含lifelines包。
Anaconda Powershell 上的 jupyter notebooks 运行,环境和包也是如此。
在Windows 电源shell 上安装将永远无法工作。 运行 Anaconda shell 中的 conda install -c conda-forge lifelines
解决了这个问题。
如此愚蠢,却如此耗时,值得分享。
我遇到了这样的问题,python3 -m pip install <package_name>
帮我解决了。将 python -m pip install <package_name>
用于 Python2。