好了,到目前爲止,我的解決方案是完全卸載EPD和蟒蛇,然後重新安裝蟒蛇和一切再次工作。起初我以爲這是因爲Anaconda和EPD在一起玩的不好。但我也嘗試再次卸載Anaconda,然後安裝EPD,仍然得到相同的錯誤。我確認安裝了mingw,這次安裝EPD時它會自動附加到我的路徑中。
如果你想嘗試重建這個錯誤嘗試在Windows 7上安裝EPD canopy-1.4.0-win-64
64位,並嘗試使用例如%%cython
細胞魔法IPython的筆記本電腦創建一個簡單的用Cython功能:
%load_ext cythonmagic
In [18]:
%%cython
cimport cython
cpdef f(int x):
cdef int y = x+2*100
return y
---------------------------------------------------------------------------
DistutilsPlatformError Traceback (most recent call last)
<ipython-input-18-326d9aaeb05c> in <module>()
----> 1 get_ipython().run_cell_magic(u'cython', u'', u'cimport cython\ncpdef f(int x):\n cdef int y = x+2*100\n return y')
C:\Users\Patrick\User\lib\site-packages\IPython\core\interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
2160 magic_arg_s = self.var_expand(line, stack_depth)
2161 with self.builtin_trap:
-> 2162 result = fn(magic_arg_s, cell)
2163 return result
2164
C:\Users\Patrick\User\lib\site-packages\IPython\extensions\cythonmagic.pyc in cython(self, line, cell)
C:\Users\Patrick\User\lib\site-packages\IPython\core\magic.pyc in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):
C:\Users\Patrick\User\lib\site-packages\IPython\extensions\cythonmagic.pyc in cython(self, line, cell)
266 build_extension.build_temp = os.path.dirname(pyx_file)
267 build_extension.build_lib = lib_dir
--> 268 build_extension.run()
269 self._code_cache[key] = module_name
270
C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\lib\distutils\command\build_ext.py in run(self)
335
336 # Now actually compile and link everything.
--> 337 self.build_extensions()
338
339 def check_extensions_list(self, extensions):
C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\lib\distutils\command\build_ext.py in build_extensions(self)
444
445 for ext in self.extensions:
--> 446 self.build_extension(ext)
447
448 def build_extension(self, ext):
C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\lib\distutils\command\build_ext.py in build_extension(self, ext)
494 debug=self.debug,
495 extra_postargs=extra_args,
--> 496 depends=ext.depends)
497
498 # XXX -- this is a Vile HACK!
C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\lib\distutils\msvc9compiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
512
513 if not self.initialized:
--> 514 self.initialize()
515 compile_info = self._setup_compile(output_dir, macros, include_dirs,
516 sources, depends, extra_postargs)
C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\lib\distutils\msvc9compiler.py in initialize(self, plat_name)
422 PLAT_TO_VCVARS[plat_name]
423
--> 424 vc_env = query_vcvarsall(VERSION, plat_spec)
425
426 # take care to only use strings in the environment.
C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\lib\distutils\msvc9compiler.py in query_vcvarsall(version, arch)
304 if vs_info is None:
305 raise DistutilsPlatformError(
--> 306 '\n'.join((VS_NOT_FOUND_MESSAGE, MINGW_DEFLECT_MESSAGE)))
307
308 vcvarsall, is_express = vs_info
DistutilsPlatformError: Could not find Visual Studio 2008 in your path.
If you do not have Visual Studio 2008 installed, you can use
the MinGW compiler instead. To install mingw, do:
enpkg mingw
To use the MinGW compiler to build an extension module, use
the '-c' flag, e.g.:
python setup.py build_ext -c mingw64
Note that building Python extensions with MinGW is not officially
supported, although it is known to work in many cases.
我以前也加入到distutils.cfg
與C:\Users\Patrick\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.0.1938.win-x86_64\Lib\distutils
如下:
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
但還是同樣的問題。有沒有人能夠在ipython中使用%%cython
作爲所提到的平臺而沒有完整版本的VS 2008?
也試過這個'C:\用戶\ Patrick \ User \ Lib \ site-packages \ mingw-4.8.1-2.egg \ EGG-INFO \ usr \ bin'這應該是正確的位置。我以前在Anaconda爲了使mingw工作,我還記得在''build''下設置'compiler = mingw32',在'disutils.cfg'中設置'[build_ext]',但是這個文件在EPD中找不到。任何人都可以告訴我在哪裏可以找到這個文件,所以我可以試試嗎? – pbreach
嘗試過'%% cython -c = mingw32'和'%% cython -compiler = mingw'沒有成功。安裝了Visual Studio 2008速成版,它給出了同樣的錯誤,並附加一條說明,完整版本是64位系統所需的,而不是快速版本。這成爲一個真正的痛苦。 – pbreach
[我使用Canopy組合MinGW沒有問題,請參考我對此問題的回答。](http://stackoverflow.com/a/36511007/5853731) –