将通过 Homebrew 安装的模块导入 Python
Importing modules installed via Homebrew into Python
使用自制软件安装图形工具
$ brew install graph-tool
安装成功。现在,当我尝试在 python shell 中导入模块时,使用 from graph_tool.all import *
我收到 ModuleNotFoundError:没有名为 'graph_tool' 的模块错误
Python 版本信息- Python 3.8.5,通过 pyenv 安装在 /Users/aamodpant/.pyenv/shims/python
graph-tool 安装在 /usr/local/Cellar/graph-tool
如何将其导入我的 python 程序?
这看起来与 post 中的问题非常相似:How to let python3 import graph-tool installed by Homebrew?
看看 NatKost 提供的最佳答案,他们在 graph-tool 和 Python 包之间创建了一个符号 link:
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
您应该能够针对您的 graph-tool 安装和 venv 进行调整。
查看此站点here and see whehter your problem is fixed. Alternatively, check this post here
我建议使用 pip
.
安装
感谢@Robert Young,带我到右边post How to let python3 import graph-tool installed by Homebrew?
因为 numpy 和 scipy 是 graph-tool 的依赖项,它们是在安装 graph-tool 时使用 home-brew 自动安装的。
编辑 linked 解决方案中显示的命令后,我在 graph-tool 和我的 python
之间添加了符号 link
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
在 numpy、scipy 和 python
之间添加了类似的 links
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
使用自制软件安装图形工具
$ brew install graph-tool
安装成功。现在,当我尝试在 python shell 中导入模块时,使用 from graph_tool.all import *
我收到 ModuleNotFoundError:没有名为 'graph_tool' 的模块错误
Python 版本信息- Python 3.8.5,通过 pyenv 安装在 /Users/aamodpant/.pyenv/shims/python
graph-tool 安装在 /usr/local/Cellar/graph-tool
如何将其导入我的 python 程序?
这看起来与 post 中的问题非常相似:How to let python3 import graph-tool installed by Homebrew?
看看 NatKost 提供的最佳答案,他们在 graph-tool 和 Python 包之间创建了一个符号 link:
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
您应该能够针对您的 graph-tool 安装和 venv 进行调整。
查看此站点here and see whehter your problem is fixed. Alternatively, check this post here
我建议使用 pip
.
感谢@Robert Young,带我到右边post How to let python3 import graph-tool installed by Homebrew?
因为 numpy 和 scipy 是 graph-tool 的依赖项,它们是在安装 graph-tool 时使用 home-brew 自动安装的。
编辑 linked 解决方案中显示的命令后,我在 graph-tool 和我的 python
之间添加了符号 linkln -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
在 numpy、scipy 和 python
之间添加了类似的 linksln -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