如何使用apt安装python-pybind11?

6

我在项目文档中看到需要使用以下命令安装python-pybind11:

sudo apt -y install python-pybind11

但我遇到了这样的错误:

正在读取软件包列表... 完成

正在构建依赖关系树
正在读取状态信息... 完成

E: 无法定位软件包 python-pybind11

我不确定 python-pybind11 是否是一个有效的软件包,我在哪里可以检查它?


欢迎,python-pybind11 是适用于 Ubuntu 18.04 及更高版本的有效软件包。 - GAD3R
@Felix Xu,你应该接受正确的答案。 - PrakashG
4个回答

7
在某些系统中,您可能需要
sudo apt -y install python3-pybind11

6

使用以下命令安装pybind11:

pip install pybind11

参考自这里


运行命令后,我得到了以下结果:Collecting pybind11 Downloading https://files.pythonhosted.org/packages/f2/7c/e71995e59e108799800cb0fce6c4b4927914d7eada0723dd20bae3b51786/pybind11-2.2.4-py2.py3-none-any.whl (145kB) 100% |████████████████████████████████| 153kB 13kB/s 安装收集的软件包:pybind11 由于出现环境错误而无法安装软件包:[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pybind11' 考虑使用“--user”选项或检查权限。 - user10838321
@FeilixXu,似乎是权限问题。请使用“sudo”运行此命令。 - PrakashG
现在又出现了一个错误:Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main ImportError: cannot import name main 。我正在使用Ubuntu16,这是否有关? - user10838321
1
请不要使用 sudo pip install!考虑使用 pip install --user,但最好尝试使用 virtualenv - eacousineau

5
在Ubuntu 18.04中,
apt-get install python-pybind11

在Mac上,

brew install pybind11

在Ubuntu 16.04中,您需要自行安装。一种方法如下:
# Some prerequisites (but not all of them)
apt-get install cmake
pip3 install pytest

# Clone, build and install 
git clone https://github.com/pybind/pybind11.git 
cd pybind11 
mkdir build 
cd build 
cmake .. 
make install

Reference


我使用了您在这里的指示。 - Foad S. Farimani

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接