bla*_*laz 16 python cygwin distutils mingw visual-studio
我试图使用cygwin(mingw)在Windows 10上使用Python 3.5运行一些代码.确切地说,我使用的是PyDSTool模块,我称之为dopri积分器.问题是,我distutils无法识别Microsoft Visual Studio 2015.有没有办法避免这种情况(没有回到旧版本的Python,Windows,Visual Studio).下面可以看到完整的错误.
ValueError Traceback (most recent call last)
<ipython-input-16-bfeb915bfd7b> in <module>()
60 print("\n")
61
---> 62 testODE = Dopri_ODEsystem(DSargs)
63
64 print('Integrating...')
C:\Anaconda3\lib\site-packages\PyDSTool\Generator\Dopri_ODEsystem.py in __init__(self, kw)
371 print("stages using the makeLibSource and compileLib methods.")
372 else:
--> 373 self.makeLib()
374
375 @property
C:\Anaconda3\lib\site-packages\PyDSTool\Generator\mixins.py in makeLib(self, libsources, libdirs, include)
98 self.forceLibRefresh()
99 self.makeLibSource(include)
--> 100 self.compileLib(libsources, libdirs)
101
102 @property
C:\Anaconda3\lib\site-packages\PyDSTool\Generator\mixins.py in compileLib(self, libsources, libdirs)
78 precompiled libraries."""
79
---> 80 self._builder.build(libsources, libdirs, self._compiler)
81
82 def forceLibRefresh(self):
C:\Anaconda3\lib\site-packages\PyDSTool\Generator\mixins.py in build(self, libsources, libdirs, compiler)
187 script_args=script_args,
188 ext_modules=[extmod],
--> 189 py_modules=[self.modname])
190
191 def save_vfield(self, code, fname=None):
C:\Anaconda3\lib\site-packages\numpy\distutils\core.py in setup(**attr)
167 new_attr['distclass'] = NumpyDistribution
168
--> 169 return old_setup(**new_attr)
170
171 def _check_append_library(libraries, item):
C:\Anaconda3\lib\distutils\core.py in setup(**attrs)
146 if ok:
147 try:
--> 148 dist.run_commands()
149 except KeyboardInterrupt:
150 raise SystemExit("interrupted")
C:\Anaconda3\lib\distutils\dist.py in run_commands(self)
953 """
954 for cmd in self.commands:
--> 955 self.run_command(cmd)
956
957 # -- Methods that operate on its Commands --------------------------
C:\Anaconda3\lib\distutils\dist.py in run_command(self, command)
972 cmd_obj = self.get_command_obj(command)
973 cmd_obj.ensure_finalized()
--> 974 cmd_obj.run()
975 self.have_run[command] = 1
976
C:\Anaconda3\lib\site-packages\numpy\distutils\command\build_ext.py in run(self)
115 verbose=self.verbose,
116 dry_run=self.dry_run,
--> 117 force=self.force)
118 self.compiler.customize(self.distribution)
119 self.compiler.customize_cmd(self)
C:\Anaconda3\lib\site-packages\numpy\distutils\ccompiler.py in new_compiler(plat, compiler, verbose, dry_run, force)
594 raise DistutilsModuleError(("can't compile C/C++ code: unable to find class '%s' " +
595 "in module '%s'") % (class_name, module_name))
--> 596 compiler = klass(None, dry_run, force)
597 log.debug('new_compiler returns %s' % (klass))
598 return compiler
C:\Anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py in __init__(self, verbose, dry_run, force)
56
57 distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose,
---> 58 dry_run, force)
59
60 # we need to support 3.2 which doesn't match the standard
C:\Anaconda3\lib\distutils\cygwinccompiler.py in __init__(self, verbose, dry_run, force)
159 # Include the appropriate MSVC runtime library if Python was built
160 # with MSVC 7.0 or later.
--> 161 self.dll_libraries = get_msvcr()
162
163 def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
C:\Anaconda3\lib\distutils\cygwinccompiler.py in get_msvcr()
88 # return ['vcruntime140']
89 else:
---> 90 raise ValueError("Unknown MS Compiler version %s " % msc_ver)
91
92
ValueError: Unknown MS Compiler version 1900
Run Code Online (Sandbox Code Playgroud)
Ind*_*lal 14
我做了以下更改,并通过以下配置为我工作.
我做了以下
C:\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev0\mingw64\bin对我来说)gcc工作(我没有其他编译器)distutils.cfg于C:\Python36\Lib\distutils在该文件中添加行:
[build]
compiler = mingw32
Run Code Online (Sandbox Code Playgroud)手动应用此修补程序
vcruntime140.dll并将其放入C:\Python36\libstha*_*ren 10
Distutils和Numpy/Distutils目前不支持Visual Studio 2015,Visual C++ 14.根据Python错误报告提示,我能够使用Anaconda的新安装的Python 3.5修补必要的文件并成功构建扩展. Mingw64与GCC 5.2.0在Windows 7上的MSYS2中运行.我没有安装Visual Studio.解决方案是修补一个distutils文件和两个numpy/distutils文件(如果适用).这些补丁已提交包含在将来的修订版中.
您可以自行应用修补程序以进行快速修复:
UPDATE
请注意,虽然上面的补丁对我有用,但不允许包含在上游.VS 2015带来的变化比我赞赏的更复杂.
小智 8
如果有人仍然有这个问题,我只是在安装yowsup和python-axolotl时遇到它,这就是我所做的解决它:
1-将来自Tharen的补丁应用到python cygwinccompiler.py文件(位于python安装文件夹中)https://bugs.python.org/file40608/patch.diff
2 - 使用mingw,安装pexports,以管理员模式打开终端并键入:
mingw-get install pexports
Run Code Online (Sandbox Code Playgroud)
2 - 转到python安装文件夹,在我的例子中它是C:\ Program Files(x86)\ Python36-32
仍然在我们用于安装pexports的同一终端中,导航到python安装文件夹后运行以下命令:
pexports vcruntime140.dll >libs\vcruntime140.def
dlltool -dllname vcruntime140.dll --def libs\vcruntime140.def --output-lib libs\libvcruntime140.a
Run Code Online (Sandbox Code Playgroud)
然后返回到您正在安装库的文件夹,或者之前正在执行的任何操作,它现在应该可以正常工作.
顺便说一句,别忘了添加
[build]
compiler = mingw32
Run Code Online (Sandbox Code Playgroud)
在distutils文件中.
资料来源:这篇帖子和https://bugs.python.org/issue25251
我正在运行同样的问题,并发现问题出在mingw编译器上.我尝试了@tharen建议的补丁,但它对我不起作用.
似乎cygwin最喜欢的windows编译器是visual c ++,所以我从http://landinghub.visualstudio.com/visual-cpp-build-tools下载了visual c ++ build工具 ,然后它工作正常.
请注意,您需要卸载mingw以及项目中包含的对它的所有引用.特别是我不得不删除我创建的distutils.cfg文件,该文件具有指向mingw的以下代码
[build]
compiler = mingw32
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18006 次 |
| 最近记录: |