git 错误:无法为pyconcorde构建wheel,这是安装基于pyproject.toml的项目所必需的

qq24tv8q  于 2023-04-04  发布在  Git
关注(0)|答案(1)|浏览(523)

我正在尝试在windows(https://github.com/jvkersch/pyconcorde)上安装pyconcorde。我已经使用了这个:

pip install -e git+https://github.com/jvkersch/pyconcorde.git#egg=pyconcorde

但我得到这个错误:

ERROR: Failed building editable for pyconcorde
ERROR: Could not build wheels for pyconcorde, which is required to install pyproject.toml-based projects

我正在使用Python 3.9.7和Windows 11。
系统建议这样做,但即使在没有可编辑模式的情况下安装,同样的问题仍然存在:

68bkxrlz

68bkxrlz1#

我能够解决这个问题。这个错误似乎是由编译和链接库之间的不兼容性与clang和GCC编译,这和底层的协和库没有配置MacOSX。
1.在运行pip install -e .之前,您必须进入./pyconcorde/build/concorde目录并手动配置它以构建和编译Concorde。
1.重要的是要取消别名gcc,然后设置GCC export CC="/usr/local/Cellar/gcc/12.2.0/bin/gcc-12"的位置
1.此时,您可以设置导出QSOPTDIR= pwd/QSOPT和导出CFLAGS="-g -O3 -arch x86_64”,运行configure和build。
1.现在,您可以返回并设置Concorde和QSOPT库的位置,然后运行pip install -e。
1.加载Python并使用Concorde Package 器
一个关键的方面是告诉python Package 器Concorde和qsopt二进制文件的位置。

export QSOPT_DIR=`pwd`/build/concorde/QSOPT
export CONCORDE_DIR=`pwd`/build/concorde/

错误解决:

git clone https://github.com/jvkersch/pyconcorde
cd pyconcorde
unalias gcc
export CC="/usr/local/Cellar/gcc/12.2.0/bin/gcc-12"
cd build/concorde
mkdir QSOPT;cd QSOPT
wget 'https://www.math.uwaterloo.ca/~bico/qsopt/downloads/codes/mac64/qsopt.gz'
wget 'https://www.math.uwaterloo.ca/~bico/qsopt/downloads/codes/mac64/qsopt.a.gz'
wget 'https://www.math.uwaterloo.ca/~bico/qsopt/downloads/codes/mac64/qsopt.h'
gunzip qsopt.a.gz
cd ..
export QSOPTDIR=`pwd`/QSOPT
export CFLAGS="-g -O3 -arch x86_64"
./configure --with-qsopt=$QSOPTDIR --host=darwin
make

# Check build succeeded
ls -la TSP/concorde

# go back to pyconcorde directory
cd ../../
export QSOPT_DIR=`pwd`/build/concorde/QSOPT
export CONCORDE_DIR=`pwd`/build/concorde/
pip install -e . 
Obtaining file:///Users/.../pyconcorde
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cython>=0.22.0 in /usr/local/lib/python3.11/site-packages (from pyconcorde==0.1.0) (0.29.33)
Requirement already satisfied: numpy>=1.10.0 in /usr/local/lib/python3.11/site-packages (from pyconcorde==0.1.0) (1.24.2)
Installing collected packages: pyconcorde
  Running setup.py develop for pyconcorde
Successfully installed pyconcorde-0.1.0

python3
Python 3.11.2 (main, Mar 24 2023, 00:31:37) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from concorde.tsp import TSPSolver
>>>

相关问题