【问题标题】:"No Module named sqlalchemy" after having just installed it from IPython prompt刚刚从 IPython 提示符安装后“没有名为 sqlalchemy 的模块”
【发布时间】:2017-09-15 14:11:25
【问题描述】:

我无法导入 sqlalchemy。我搜索并找到了一些解决方案,例如安装 flask 或 flask_sqlalchemy 等。这些都没有帮助。

我错过了什么?

【问题讨论】:

  • 试试pip --version 它说了什么?您可能必须改用pip3
  • 来自 /usr/local/lib/python3.4/site-packages (python 3.4) 的 pip 9.0.1。我也尝试过 pip3 。没有运气。

标签: python python-3.4


【解决方案1】:

有时,您需要重新启动 ipython 才能找到新安装的模块。

我相信这适用于添加到 sys.path 的模块。


根据 Can I zip all the python standard libs and the python still able to import it?site.main() 也应该可以工作。

它会扫描site-packages 目录中的.pth 文件并将其内容添加到sys.path。由于它的逻辑会在添加之前检查重复项,因此在重复调用时它不应该使 sys.path 混乱。

【讨论】:

  • 实际上在 ipython 中重新启动内核已经解决了这个问题。谢谢!
  • @ArvindKandaswamy 你是怎么做到的?我看到stackoverflow.com/questions/26603456/reset-ipython-kernel,但没有明确的答案。
  • 我是在 jupyter 中通过从 jupyter 菜单中选择 kernel->restart 来完成的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-02-20
  • 1970-01-01
  • 2013-11-07
  • 1970-01-01
  • 2015-05-02
  • 1970-01-01
  • 2012-10-17
相关资源
最近更新 更多