如何解决在 Debian 测试中使用旧的?Python3 模块安装 Cantera 以运行 SCons 脚本时遇到问题
更新
这是 cantera 的链接:enter link description here 我确实安装了 scons;
apt-cache policy scons*
scons:
Installed: 4.0.1+dfsg-2
Candidate: 4.0.1+dfsg-2
Version table:
*** 4.0.1+dfsg-2 900
900 http://deb.debian.org/debian testing/main amd64 Packages
100 /var/lib/dpkg/status
3.0.1-2 500
500 http://http.us.debian.org/debian stable/main amd64 Packages
直接链接到来源:
scons build prefix='/home/X/SW/Cantera/installed/' --config=force
我一直在尝试升级/安装 Cantera (cantera.org),它依赖于 Scons(使用了脚本“SConstruct”)。我注意到脚本中有一行,from buildutils import *
。我尝试使用 python3 -m pip install --user buildutils
安装它,但出现了一个大错误:
2016|0|X@X ~/SW/Cantera/cantera $ Wed 7 04 2021,13:24:08
python3 -m pip install --user buildutils
Collecting buildutils
Using cached buildutils-0.3.tar.gz (47 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-owjzbfid
cwd: /tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/
Complete output (8 lines):
Traceback (most recent call last):
File "<string>",line 1,in <module>
File "/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/setup.py",line 5,in <module>
from ez_setup import use_setuptools
File "/tmp/pip-install-v3fu4kdk/buildutils_3a844402d1bc49ec99a3331d798a6021/ez_setup.py",line 91
except pkg_resources.VersionConflict,e:
^
SyntaxError: invalid Syntax
----------------------------------------
WARNING: discarding https://files.pythonhosted.org/packages/b2/84/797607896d265c2bf00cdaff35c901713f738dfc4efe8ee23bdedb42c789/buildutils-0.3.tar.gz#sha256=8f9921cf145a1879986b4028db0af4f028f65fe6eae29936490174037ba7dfc5 (from https://pypi.org/simple/buildutils/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached buildutils-0.1.2.tar.gz (42 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/setup.py'"'"';f=getattr(tokenize,'"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-28mf5gk7
cwd: /tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/
Complete output (8 lines):
Traceback (most recent call last):
File "<string>",in <module>
File "/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/setup.py",in <module>
from ez_setup import use_setuptools
File "/tmp/pip-install-v3fu4kdk/buildutils_861964493705449c937dc2face33fe7e/ez_setup.py",line 160
print "Setuptools successfully installed or upgraded."
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Setuptools successfully installed or upgraded.")?
----------------------------------------
WARNING: discarding https://files.pythonhosted.org/packages/d7/62/b25a56b638d9e1cfc08eba7fd0aa5876f3e2c86f30ca4c5b8c3cda2af524/buildutils-0.1.2.tar.gz#sha256=ad9d597e6836535010880128e5614145f84939c7e26a64c186a7eb37454fa8db (from https://pypi.org/simple/buildutils/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement buildutils
ERROR: No matching distribution found for buildutils
我看到“版本冲突”和括号问题....我还注意到最新版本是 2007 年的...https://pypi.org/project/buildutils/ 是否有更新的替代版本?
我想尝试从源代码手动安装它(egg 文件显然是为 python2 构建的),但无法成功执行 ez_setup.py
或 setup.py
而没有错误。我关注了一页,但在不确定发生了什么之前从未这样做过。
我在互联网上看到很多关于找不到模块的请求,但大多数答案都围绕着错误命名 (Can't install PyZMP for Python -- Dependencies) 或未安装。
我从 Debian 存储库中搜索了与 buildutils
相关的内容,但没有找到相关内容。
这源于我从 scons 脚本中得到的关于 keyvalue
的错误,此处显示了相关部分:
...
...
--------------------- end config.log ---------------------
INFO: Using NumPy version 1.19.5.
INFO: Using Cython version 0.29.21.
INFO: Building the full Python package for Python 3.9
KeyError: 'HAS_CLANG':
File "/home/X/SW/Cantera/cantera/SConstruct",line 1543:
if env['OS'] == 'Solaris' or env['HAS_CLANG']:
File "/home/X/.local/lib/python3.9/site-packages/SCons/Environment.py",line 388:
return self._dict[key]
所以脚本 SConstruct
的 1543 行是;
...
196 env = Environment(tools=toolchain+['textfile','subst','recursiveInstall','wix','gch'],197 ENV={'PATH': os.environ['PATH']},198 toolchain=toolchain,199 **extraEnvArgs)
200
201 env['OS'] = platform.system()
202 env['OS_BITS'] = int(platform.architecture()[0][:2])
...
825 conf = Configure(env,custom_tests={'CheckStatement': CheckStatement})
...
1032 env['HAS_CLANG'] = conf.CheckDeclaration('__clang__','','C++')
...
1526
1527 configh = {}
1528
1529 configh['CANtera_VERSION'] = quoted(env['cantera_version'])
1530 configh['CANtera_SHORT_VERSION'] = quoted(env['cantera_short_version'])
1531
1532 # Conditional defines
1533 def cdefine(definevar,configvar,comp=True,value=1):
1534 if env.get(configvar) == comp:
1535 configh[definevar] = value
1536 else:
1537 configh[definevar] = None
1538
1539 # Need to test all of these to see what platform.system() returns
1540 configh['SOLARIS'] = 1 if env['OS'] == 'Solaris' else None
1541 configh['DARWIN'] = 1 if env['OS'] == 'Darwin' else None
1542
1543 if env['OS'] == 'Solaris' or env['HAS_CLANG']:
1544 configh['NEEDS_GENERIC_TEMPL_STATIC_DECL'] = 1
1545
1546 configh['CT_SUNDIALS_VERSION'] = env['sundials_version'].replace('.','')
1547
1548 if env.get('has_sundials_lapack') and env['use_lapack']:
1549 configh['CT_SUNDIALS_USE_LAPACK'] = 1
1550 else:
1551 configh['CT_SUNDIALS_USE_LAPACK'] = 0
1552
1553 cdefine('LAPACK_FTN_STRING_LEN_AT_END','lapack_ftn_string_len_at_end')
这看起来只是一本字典,即这里的快速入门部分:enter link description here 但我在目录 (def Environment
) 所以我认为它可能是这个模块 grep -nRHI "def Environment" *
的一部分。这然后解释了为什么我尝试安装它以及随后的错误。我意识到我可以尝试只注释掉第 1543 行和取消缩进第 1544 行,因为我确实有叮当声,但我不确定我是否有“正确”的叮当声...
编辑
我确实有 buildutils
,并搜索 PyPl,也许这是替代品.... buildutil
的 mercurial 存储库链接似乎不起作用,但也许我可以只 {{1 }} 替换整个项目中的名称...我也在 https://pypi.org/project/buildutil/ 上看到它可能只对 python3.6 有用...
编辑 2
我现在想知道它是否不仅仅是重命名...,因为这两个名称都列在 https://github.com/tedicreations/buildutil 上...所以也许只是 buildutils
脚本将名称从 {{1 }} 到 awk
...
编辑 3
根据 awk
的建议,我尝试了这些更改;
buildutils
但是在 buildutil
和 2to3
之后,错误仍然存在(可能是字典问题...);
2to3 -f all -w SConstruct
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored SConstruct
--- SConstruct (original)
+++ SConstruct (refactored)
@@ -37,7 +37,7 @@
'scons doxygen' - Build the Doxygen documentation
"""
-from __future__ import print_function
+
from buildutils import *
if not COMMAND_LINE_TARGETS:
@@ -216,7 +216,7 @@
# Fix an issue with Unicode sneaking into the environment on Windows
if os.name == 'nt':
- for key,val in env['ENV'].items():
+ for key,val in list(env['ENV'].items()):
env['ENV'][key] = str(val)
if 'FRAMEWORKS' not in env:
@@ -327,7 +327,7 @@
defaults.python_prefix = '$prefix' if env['OS'] != 'Windows' else ''
# Transform lists into strings to keep cantera.conf clean
-for key,value in defaults.__dict__.items():
+for key,value in list(defaults.__dict__.items()):
if isinstance(value,(list,tuple)):
setattr(defaults,key,' '.join(value))
@@ -660,7 +660,7 @@
# Expand ~/ and environment variables used in cantera.conf (variables used on
# the command line will be expanded by the shell)
-for option in opts.keys():
+for option in list(opts.keys()):
original = env[option]
if isinstance(original,str):
modified = os.path.expandvars(os.path.expanduser(env[option]))
RefactoringTool: Files that were modified:
RefactoringTool: SConstruct
我注意到,scons clean
的规则可能无法将模块从 scons test-clean
转换为 scons build prefix='/home/X/SW/Cantera/installed/' --config=force
scons: Reading sconscript files ...
INFO: SCons is using the following Python interpreter: /usr/bin/python3
Configuration variables read from 'cantera.conf' and command line:
prefix = '/home/X/SW/Cantera/installed/'
Checking for C++ header file cmath... yes
Checking for C++ header file fmt/ostream.h... yes
INFO: Using system installation of fmt library.
INFO: Found fmt version 7.1.3
Checking for C++ header file yaml-cpp/yaml.h... yes
INFO: Using system installation of yaml-cpp library.
Checking for C++ header file gtest/gtest.h... no
Checking for C++ header file gmock/gmock.h... no
INFO: Using Googletest from Git submodule
Checking for C++ header file Eigen/Dense... no
INFO: Using private installation of Eigen.
INFO: Found Eigen version 3.3.7
Checking whether __GLIBCXX__ is declared... yes
Checking whether __clang__ is declared... no
Checking for C++ header file omp.h... yes
INFO: Found Boost version 1.74
Checking whether boost::core::demangle is declared... yes
Checking for CVodeCreate(CV_BDF,CV_NEWTON) in C++ library sundials_cvodes... no
Checking for CVodeCreate(CV_BDF) in C++ library sundials_cvodes... yes
Checking for double x; log(x) in C library None... no
INFO: Using system installation of Sundials version 4.1.0.
Checking whether SUNDIALS_BLAS_LAPACK is declared... yes
sh: 1: .sconf_temp/conftest_9d002cee8d847914673abd8559024f70_0_3ae94ee097a5c84b400a349871c73680: not found
WARNING: Unable to use 'gfortran' to compile the Fortran interface. See config.log for details.
INFO: Skipping compilation of the Fortran 90 interface.
INFO: Using NumPy version 1.19.5.
INFO: Using Cython version 0.29.21.
INFO: Building the full Python package for Python 3.9
KeyError: 'HAS_CLANG':
File "/home/X/SW/Cantera/cantera/SConstruct",line 1542:
if env['OS'] == 'Solaris' or env['HAS_CLANG']:
File "/home/X/.local/lib/python3.9/site-packages/SCons/Environment.py",line 388:
return self._dict[key]
,如果这确实是一个适当的更改...
还有……
这是来自 2to3
模块,因为它没有摆脱 buildutils
(我没有),尝试运行它似乎毫无意义......我做到了...还是一样的错误。
buildutil
解决方法
一些旧包可以用 2to3 tool 修复,在旧源文件夹上运行它,然后尝试用 python3 设置。另一种方式是安装python2。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。