首页 > 解决方案 > 使用 python3 构建 pynauty

问题描述

我正在尝试根据以下说明构建 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 构建 if)。所以我为 python3 添加了一个别名: aliast python=python3。但是当我输入makepynauty 的根目录时,我仍然收到一条消息,说检测到 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

标签: pythonpython-3.x

解决方案


编辑Makefilefor nauty

更改PYTHON = pythonPYTHON = python3, 和 PIP = pipPIP = pip3或任何你调用 Python 3 的 pip )。


推荐阅读