首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装pybind11后“没有名为pybind11的模块”

安装pybind11后“没有名为pybind11的模块”
EN

Stack Overflow用户
提问于 2020-04-16 02:13:35
回答 1查看 3K关注 0票数 3

我已经在我的Ubuntu18.04.3机器上安装了pybind11 (几种不同的方式,包括pip和包管理器),但是当我尝试指定包含文件时,推荐的方式是:

python3 -m pybind11 --includes

我得到了这个错误:

/usr/bin/python3: No module named pybind11.__main__; 'pybind11' is a package and cannot be directly executed

我唯一发现这个错误的地方是一个中文网页,这对解决这个问题没有帮助。如何让pybind11正常工作?

要回答下面的一些问题:

代码语言:javascript
复制
>>> import pybind11; print(pybind11.__file__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pybind11' has no attribute '__file__'
代码语言:javascript
复制
> python3 -m pip install pybind11
WARNING: The directory '/home/<username>/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pybind11 in /usr/local/lib/python3.6/dist-packages (2.5.0)
代码语言:javascript
复制
> sudo pip3 -V
pip 20.0.2 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
代码语言:javascript
复制
> python3 -V
Python 3.6.8
EN

回答 1

Stack Overflow用户

发布于 2020-12-21 16:26:19

尝试使用此命令。

代码语言:javascript
复制
export PYTHONPATH=$PYTHONPATH:/home/xxx/pybind11
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61235727

复制
相关文章

相似问题

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