首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ModuleNotFoundError:即使在pip失速mplfinance之后,也没有名为“mplfinance”的模块出现错误

ModuleNotFoundError:即使在pip失速mplfinance之后,也没有名为“mplfinance”的模块出现错误
EN

Stack Overflow用户
提问于 2021-08-15 06:36:38
回答 1查看 2.3K关注 0票数 0

在我的MacBook上的木星笔记本上运行这个程序会产生以下错误:

代码语言:javascript
复制
import mplfinance 

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-5bae819ae7bb> in <module>
----> 1 import mplfinance as mpl

ModuleNotFoundError: No module named 'mplfinance'

但我也安装了mplfinance并对其进行了升级。我在我的终端上做了以下工作:

代码语言:javascript
复制
~ pip3 install mplfinance
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: mplfinance in /usr/local/lib/python3.9/site-packages (0.12.7a17)
Requirement already satisfied: pandas in /usr/local/lib/python3.9/site-packages (from mplfinance) (1.3.1)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.9/site-packages (from mplfinance) (3.4.3)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (1.3.1)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (2.8.2)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (8.3.1)
Requirement already satisfied: numpy>=1.16 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (1.21.1)
Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (2.4.7)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (0.10.0)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from cycler>=0.10->matplotlib->mplfinance) (1.16.0)
Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.9/site-packages (from pandas->mplfinance) (2021.1)
➜  ~ pip install mplfinance 
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: mplfinance in /usr/local/lib/python3.9/site-packages (0.12.7a17)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.9/site-packages (from mplfinance) (3.4.3)
Requirement already satisfied: pandas in /usr/local/lib/python3.9/site-packages (from mplfinance) (1.3.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (1.3.1)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (8.3.1)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (0.10.0)
Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (2.4.7)
Requirement already satisfied: numpy>=1.16 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (1.21.1)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from cycler>=0.10->matplotlib->mplfinance) (1.16.0)
Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.9/site-packages (from pandas->mplfinance) (2021.1)
➜  ~ pip install --upgrade mplfinance
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: mplfinance in /usr/local/lib/python3.9/site-packages (0.12.7a17)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.9/site-packages (from mplfinance) (3.4.3)
Requirement already satisfied: pandas in /usr/local/lib/python3.9/site-packages (from mplfinance) (1.3.1)
Requirement already satisfied: numpy>=1.16 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (1.21.1)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (2.8.2)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (8.3.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (1.3.1)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (0.10.0)
Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/lib/python3.9/site-packages (from matplotlib->mplfinance) (2.4.7)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from cycler>=0.10->matplotlib->mplfinance) (1.16.0)
Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.9/site-packages (from pandas->mplfinance) (2021.1)
➜  ~ 

重新启动内核,甚至重新启动我的笔记本电脑,但我一直看到这个错误。这里有人会知道为什么我看到ModuleNotFoundError错误,尽管它已经安装了吗?

非常感谢

EN

回答 1

Stack Overflow用户

发布于 2021-08-15 14:27:22

这种类型的错误与mplfinance本身无关。导致“模块未找到”问题的最常见(但不仅仅是)原因(不管包是什么,假设模块已经安装)是包或模块安装在一个地方,但是python的导入路径正在寻找其他地方。

如果包是全局安装的,但是python在虚拟环境中运行(或者vis在虚拟环境中运行),就会发生这种情况。例如,如果运行jupyter notebook运行不同于安装包的版本的python (其他已安装的)版本,也可能发生这种情况。

您可以做几件事情来诊断这种情况:

  1. 您是在一个与安装mplfinance不同的虚拟环境中运行jupyter笔记本吗?(从上面的跟踪:mplfinance in /usr/local/lib/python3.9/site-packages)
  2. At,终端提示:which jupyter <enter>,这将显示您从何处运行jupyter,这可能会让您从jupyter运行的位置了解ipython,这反过来会给您提供python运行位置的信息。它是否与installed?
  3. Try在jupyter之外导入mplfinance的地方相同。例如,在终端提示符下键入:python -c "import mplfinance;print(mplfinance.__file__)"。这起作用吗?
  4. 在其他任何事情之前:导入sys打印(sys.path) print(sys.executable)

第一个打印将告诉您python在哪里查找包。第二个例子将告诉您jupyter在哪里运行python (它可能与mplfinance是installed).

  • Compare pip --version to pip3 --version的python不同,如果您安装了多个版本的

,这也会给您提供一个想法)。

另一个,但不太常见的原因,“模块找不到”是一个错误的安装。如果是这样的话,这通常可以用:pip uninstall <package>pip install --no-cache-dir <package>来修正。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68789254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档