[英]Importing modules installed via Homebrew into Python
Installed graph-tool via homebrew using $ brew install graph-tool
使用
$ brew install graph-tool
tool 通过自制软件安装图形工具
Installation was successful.安装成功。 Now, when I try to import the module in the python shell, using
from graph_tool.all import *
现在,当我尝试导入 python shell 中的模块时,使用
from graph_tool.all import *
I receive a ModuleNotFoundError: No module named 'graph_tool' error我收到ModuleNotFoundError: No module named 'graph_tool'错误
Python version info- Python 3.8.5 , installed via pyenv at /Users/aamodpant/.pyenv/shims/python
Python 版本信息- Python 3.8.5 ,通过 pyenv 安装在
/Users/aamodpant/.pyenv/shims/python
graph-tool installed in /usr/local/Cellar/graph-tool安装在/usr/local/Cellar/graph-tool 中的图形工具
How do I import this into my python program?如何将其导入我的 python 程序?
This looks like a very similar issue to the one in this post: How to let python3 import graph-tool installed by Homebrew?这看起来与这篇文章中的问题非常相似: How to let python3 import graph-tool installed by Homebrew?
Have a look at the top answer provided by NatKost where they created a symbolic link between graph-tool and the Python packages:查看 NatKost 提供的最佳答案,他们在其中创建了 graph-tool 和 Python 包之间的符号链接:
ln -s /usr/local/Cellar/graph-tool/2.26_2/lib/python3.6/site-packages/graph_tool /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
You should be able adapt this for your graph-tool install and your venv.您应该能够为您的图形工具安装和您的 venv 调整它。
Thanks @Robert Young, for leading me to the right post How to let python3 import graph-tool installed by Homebrew?感谢@Robert Young,引导我找到正确的帖子如何让 python3 导入 Homebrew 安装的图形工具?
Because numpy and scipy are dependencies of graph-tool, they were installed automatically using home-brew when installing graph-tool.因为numpy和scipy是graph-tool的依赖,安装graph-tool时使用home-brew自动安装。
After editing the command shown in the linked solution, I added a symbolic link between graph-tool and my python编辑链接解决方案中显示的命令后,我在图形工具和我的 python 之间添加了一个符号链接
ln -s /usr/local/Cellar/graph-tool/2.33/lib/python3.8/site-packages/graph_tool /Users/aamodpant/.pyenv/versions/3.8.5/lib/python3.8/site-packages
added similar links between numpy, scipy and python在 numpy、scipy 和 python 之间添加了类似链接
ln -s /usr/local/Cellar/numpy/1.19.1/lib/python3.8/site-packages/numpy /Users/aamodpant/.pyenv/versions/3.8.5/lib/python3.8/site-packages
ln -s /usr/local/Cellar/scipy/1.5.2/lib/python3.8/site-packages/scipy /Users/aamodpant/.pyenv/versions/3.8.5/lib/python3.8/site-packages
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.