尽管安装了它,为什么我仍会继续使用Pydot接收Modulenotfound错误?

发布于 2025-02-10 09:26:31 字数 887 浏览 2 评论 0原文

我已经安装了Pydot并进行了检查以确保几次。但是,当我尝试在juptyer笔记本文件中导入它时,我会一直收到一个找不到的错误:

ModuleNotFoundError: No module named 'pydot'

当我运行pip3 show pydot时,我会得到以下响应:

Name: pydot
Version: 1.4.2
Summary: Python interface to Graphviz's Dot
Home-page: https://github.com/pydot/pydot
Author: Ero Carrera
Author-email: [email protected]
License: MIT
Location: /Users/parkertemple/Library/Python/3.8/lib/python/site-packages
Requires: pyparsing
Required-by: 

当我运行时,

 python3 myscript.py

我得到了:


/usr/local/bin/python3: can't open file '/Users/(my user account)/script.py': [Errno 2] No such file or directory

我相对较新到命令行,有点挣扎。任何帮助将不胜感激。

我正在使用Mac OS。 太感谢了!

I've installed pydot and checked to make sure of this several times. However, when I attempt to import it in a Juptyer notebook file, I keep receiving a Module Not Found error:

ModuleNotFoundError: No module named 'pydot'

When I run pip3 show pydot, I get the following response:

Name: pydot
Version: 1.4.2
Summary: Python interface to Graphviz's Dot
Home-page: https://github.com/pydot/pydot
Author: Ero Carrera
Author-email: [email protected]
License: MIT
Location: /Users/parkertemple/Library/Python/3.8/lib/python/site-packages
Requires: pyparsing
Required-by: 

After, when I run

 python3 myscript.py

I get this:


/usr/local/bin/python3: can't open file '/Users/(my user account)/script.py': [Errno 2] No such file or directory

I'm relatively new to the command line and am struggling a bit. Any help would be greatly appreciated.

I'm using mac os.
Thank you so much! ????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骄兵必败 2025-02-17 09:26:31

启动时遇到这些问题并不少见。
通常这个问题与Python3有关,不了解PIP目录在何处进行安装。

在解决此问题时,您可以考虑两条途径:

  1. for Python 3.7(尝试用Python3版本替换它):

    导出pythonpath =“ $ {pythonpath}:/usr/usr/local/lib/python3.7/site-packages:/usr/lib/python3.7/site-packages”

  2. 使用 python虚拟环境。这就像制作特定的Python& PIP安装。它特别有用,因为它可以隔离您的项目所需的模块,从而使其更轻巧,可共享等。这将需要更多时间来设置。但是要了解为什么虚拟环境对您的项目有益可能非常重要。

It's not uncommon to have these problems when starting out.
Usually this problem relates to Python3 not understanding where the pip directory is making its installations.

Two paths you can consider in fixing this issue:

  1. For Python 3.7 (try replacing it with your python3 version):

    export PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.7/site-packages:/usr/lib/python3.7/site-packages"

  2. Use a Python virtual environment. This is like making a specific python & pip installation. It's particularly useful because it isolates the modules that your project needs, making it more lightweight, shareable, etc. This will take a little more time to set up; but it can be very important to understand why virtual environments are beneficial to your project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文