用python3构建pynauty

1 投票
1 回答
543 浏览
提问于 2025-06-08 05:49

我正在按照这个说明来构建pynauty:https://web.cs.dal.ca/~peter/software/pynauty/html/install.html#build

我想强调的是,我的主要目标是运行这段Python代码:https://github.com/calebh/dihash

可惜的是,我在执行pynauty的构建阶段时遇到了问题。执行make pynauty命令时,我收到了以下错误信息:

cd nauty; make nauty.o nautil.o naugraph.o schreier.o naurng.o
make[1]: Entering directory '/home/pc/pynauty-0.6.0/nauty27rc5'
make[1]: 'nauty.o' is up to date.
make[1]: 'nautil.o' is up to date.
make[1]: 'naugraph.o' is up to date.
make[1]: 'schreier.o' is up to date.
make[1]: 'naurng.o' is up to date.
make[1]: Leaving directory '/home/pc/pynauty-0.6.0/nauty27rc5'
python setup.py build
running build
running build_py
running build_ext
building 'pynauty.nautywrap' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-8kFkPd/python2.7-2.7.17=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Inauty -Isrc -I/usr/include/python2.7 -c src/nautywrap.c -o build/temp.linux-x86_64-2.7/src/nautywrap.o -O4 -fPIC
src/nautywrap.c:15:10: fatal error: Python.h: No such file or directory
   15 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
make: *** [Makefile:36: pynauty] Error 1

我猜这可能是因为我没有安装python-dev这个包(我想为python3构建)。所以我为python3添加了一个别名,使用的是:aliast python=python3。但是当我在pynauty的根目录输入make时,仍然收到一条消息,提示检测到了python2:

Available targets:

  pynauty       - build the pynauty extension module
  tests         - run all tests
  clean         - remove all python related temp files and dirs
  user-ins      - install pynauty into ~/.local/
  user-unins    - uninstall pynauty from ~/.local/
  virtenv-ins   - install pynauty into the active virtualenv
  virtenv-unins - uninstall pynauty from the active virtualenv
  dist          - create a source distribution
  docs          - build pyanauty documentation
  clean-docs    - remove pyanauty documentation
  nauty-objects - compile only nauty.o nautil.o naugraph.o schreier.o naurng.o
  nauty-progs   - build all nauty programs
  clean-nauty   - a "distclean" for nauty
  clobber       - clean + clean-nauty + clean-docs

Python version: 2 7 17
Machine type: x86_64

相关问题:

  • 暂无相关问题
暂无标签

1 个回答

1

编辑一下 nautyMakefile 文件。

PYTHON = python 改成 PYTHON = python3,同时把 PIP = pip 改成 PIP = pip3(或者你用的 Python 3 的 pip 叫别的名字也可以)。

撰写回答