Can't Compile Cython on Windows with MingW - python

On Windows 10 Build 14393 with Python 3.7.0, Cython 0.29.6 and MinGW32 located at C:\MinGW with the path C:\MinGW\bin on the system PATH environment variable, I am unable to get Cython code to compile using MingW. When I attempt to, I receive the following:
running build_ext
building 'abc_image_stats' extension
error: Unable to find vcvarsall.bat
c:\program files\python\python37\lib\site-packages\Cython\Compiler\Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\abc\Downloads\python\abc_image_stats\abc_image_stats.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
I have tried various fixes, such as those mentioned here, to no avail. After making the config file as instructed in that solution, (but before changing cgwinccompiler.py), I attempted to compile again but then received this error:
running build_ext
Traceback (most recent call last):
File "setup.py", line 7, in <module>
include_dirs=[numpy.get_include()] # https://stackoverflow.com/a/14657667
File "C:\Program Files\Python\Python37\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\Python\Python37\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\Python\Python37\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Program Files\Python\Python37\lib\distutils\command\build_ext.py", line 308, in run
force=self.force)
File "C:\Program Files\Python\Python37\lib\distutils\ccompiler.py", line 1031, in new_compiler
return klass(None, dry_run, force)
File "C:\Program Files\Python\Python37\lib\distutils\cygwinccompiler.py", line 282, in __init__
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
File "C:\Program Files\Python\Python37\lib\distutils\cygwinccompiler.py", line 157, in __init__
self.dll_libraries = get_msvcr()
File "C:\Program Files\Python\Python37\lib\distutils\cygwinccompiler.py", line 86, in get_msvcr
raise ValueError("Unknown MS Compiler version %s " % msc_ver)
ValueError: Unknown MS Compiler version 1914
c:\program files\python\python37\lib\site-packages\Cython\Compiler\Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\abc\Downloads\python\abc_image_stats\abc_image_stats.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
So then I did the last two steps; I added
elif msc_ver == '1914':
# Visual Studio 2015 / Visual C 14.0
# "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspx
return ['vcruntime140']
to the cygwinccompiler.py file and copied vcruntime140.dll to the C:\Program Files\Python\Python37\libs folder, but then I receive this error upon attempting to compile:
running build_ext
building 'abc_image_stats' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall "-IC:\Program Files\Python\Python37\lib\site-packages\numpy\core\include" "-IC:\Program Files\Python\Python37\include" "-IC:\Program Files\Python\Python37\include" -c abc_image_stats.c -o build\temp.win-amd64-3.7\Release\abc_image_stats.o
In file included from C:\Program Files\Python\Python37\include/Python.h:68:0,
from abc_image_stats.c:4:
C:\Program Files\Python\Python37\include/pytime.h:123:59: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
PyAPI_FUNC(int) _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv);
^~~~~~~
C:\Program Files\Python\Python37\include/pytime.h:130:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
struct timeval *tv,
^~~~~~~
C:\Program Files\Python\Python37\include/pytime.h:135:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
struct timeval *tv,
^~~~~~~
writing build\temp.win-amd64-3.7\Release\abc_image_stats.cp37-win_amd64.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-3.7\Release\abc_image_stats.o build\temp.win-amd64-3.7\Release\abc_image_stats.cp37-win_amd64.def "-LC:\Program Files\Python\Python37\libs" "-LC:\Program Files\Python\Python37\PCbuild\amd64" -lpython37 -lvcruntime140 -o C:\Users\abc\Downloads\python\abc_image_stats\abc_image_stats.cp37-win_amd64.pyd
C:\Program Files\Python\Python37\libs/libpython37.a: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1
c:\program files\python\python37\lib\site-packages\Cython\Compiler\Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\abc\Downloads\python\abc_image_stats\abc_image_stats.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
To be clear, my setup.py file looks like this:
from distutils.core import setup
from Cython.Build import cythonize
import numpy
setup(
ext_modules = cythonize("abc_image_stats.pyx"),
include_dirs=[numpy.get_include()] # https://stackoverflow.com/a/14657667
)
and I am attempting to compile using python setup.py build_ext --inplace via the command line.
All I want to do is compile the Cython code on a Windows 10 machine using MingW. I've tried everything I can think of and don't know what's wrong. Any ideas on how to solve this?

try to change
elif msc_ver == '1914':
return ['vcruntime140']
to return ['msvcr100']
this worked for me, don't really know why though

Related

Yet Another DLIB installation problem despite CMake installed

I have CMake tool installed using Visual STudio Build tools 2019. I have rechecked my ENV variables multiple times.
I have tried installation using the Source. I have followed this and all the other discussions as well.
Here is the detailed error
running install
C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\command\easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running bdist_egg
running egg_info
writing tools/python\dlib.egg-info\PKG-INFO
writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt
writing top-level names to tools/python\dlib.egg-info\top_level.txt
package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools\python\build*'
no previously-included directories found matching 'dlib\cmake_utils\*\build*'
no previously-included directories found matching 'dlib\test'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(cmake_version) < '3.1.0':
Building extension for Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\lib
.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\asus\PycharmProjects\drowsiness-detection\envt\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\lib.win-amd64-3.10 -A x64'
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.22000.
CMake Error at CMakeLists.txt:14 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 27-Feb-22 6:58:45 PM.
Project "C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\temp.win-amd64-3.10\Release\CMakeFiles\3.18.4\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.17763.0
was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\temp.win-amd64-3.10\Release\CMakeFiles\3.18.4\VCTargetsPath.vcxproj]
Done Building Project "C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\temp.win-amd64-3.10\Release\CMakeFiles\3.18.4\VCTargetsPath.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\temp.win-amd64-3.10\Release\CMakeFiles\3.18.4\VCTargetsPath.vcxproj" (default target) (1) ->
(_CheckWindowsSDKInstalled target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.17763
.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\build\temp.win-amd64-3.10\Release\CMakeFiles\3.18.4\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.21
Exit code: 1
-- Configuring incomplete, errors occurred!
See also "C:/Users/asus/Downloads/dlib-19.23.0/dlib-19.23.0/build/temp.win-amd64-3.10/Release/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
File "C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\setup.py", line 222, in <module>
setup(
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\__init__.py", line 155, in setup
return distutils.core.setup(**attrs)
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
return run_commands(dist)
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
dist.run_commands()
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\command\install.py", line 74, in run
self.do_egg_install()
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\command\install.py", line 116, in do_egg_install
self.run_command('bdist_egg')
File "C:\Users\asus\PycharmProjects\drowsiness-detection\envt\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
self.build_extension(ext)
File "C:\Users\asus\Downloads\dlib-19.23.0\dlib-19.23.0\setup.py", line 171, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "C:\Users\asus\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\asus\\Downloads\\dlib-19.23.0\\dlib-19.23.0\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\asus\\Downloads\\dlib-19.23.0\\dlib-19.23.0\\build\\lib.win-amd64-3.10', '-DPYTHON_EXECUTABLE=C:\\Users\\asus\\PycharmProjects\\drowsiness-detection\\envt\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\asus\\Downloads\\dlib-19.23.0\\dlib-19.23.0\\build\\lib.win-amd64-3.10', '-A', 'x64']' returned non-zero exit status 1.
I am not using Anacodna and I am on Windows 10 platform. Any help is much appreciated.
Do you have Windows SDK version 10.0.17763.0 installed? It should look something like this screenshot:

Installing pygame problem "Microsoft Visual C++ 14.1 is required"

I tried to install pygame but i get this error:
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.1 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
Collecting pygame==2.0.0.dev6
Using cached https://files.pythonhosted.org/packages/c5/a0/63f9ca836e6a08e560f1ef3f2535ffb46bfdad2abb093dd097dae252be28/pygame-2.0.0.dev6.tar.gz
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip 0bbac0106358dc99b8ba2401ae6a1c10d3927ca9
Unzipping :prebuilt_downloads\SDL2-devel-2.0.10-VC.zip:
Downloading... https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.5-VC.zip 137f86474691f4e12e76e07d58d5920c8d844d5b
Unzipping :prebuilt_downloads\SDL2_image-devel-2.0.5-VC.zip:
Downloading... https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.14-VC.zip c64d90c1f7d1bb3f3dcfcc255074611f017cdcc4
Unzipping :prebuilt_downloads\SDL2_ttf-devel-2.0.14-VC.zip:
Downloading... https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-2.0.4-VC.zip 9097148f4529cf19f805ccd007618dec280f0ecc
Unzipping :prebuilt_downloads\SDL2_mixer-devel-2.0.4-VC.zip:
Downloading... https://www.ijg.org/files/jpegsr9c.zip 9ca086c960ffc4bff821ba194c8d0a15f69eae09
Unzipping :prebuilt_downloads\jpegsr9c.zip:
Downloading... https://bitbucket.org/llindstrom/pygame/downloads/prebuilt-x86-pygame-1.9.2-20150922.zip dbce1d5ea27b3da17273e047826d172e1c34b478
Unzipping :prebuilt_downloads\prebuilt-x86-pygame-1.9.2-20150922.zip:
copying into .\prebuilt-x86
Path for SDL: prebuilt-x86\SDL2-2.0.10
...Library directory for SDL: prebuilt-x86/SDL2-2.0.10/lib/x86
...Include directory for SDL: prebuilt-x86/SDL2-2.0.10/include
Path for FONT: prebuilt-x86\SDL2_ttf-2.0.14
...Library directory for FONT: prebuilt-x86/SDL2_ttf-2.0.14/lib/x86
...Include directory for FONT: prebuilt-x86/SDL2_ttf-2.0.14/include
Path for IMAGE: prebuilt-x86\SDL2_image-2.0.5
...Library directory for IMAGE: prebuilt-x86/SDL2_image-2.0.5/lib/x86
...Include directory for IMAGE: prebuilt-x86/SDL2_image-2.0.5/include
Path for MIXER: prebuilt-x86\SDL2_mixer-2.0.4
...Library directory for MIXER: prebuilt-x86/SDL2_mixer-2.0.4/lib/x86
...Include directory for MIXER: prebuilt-x86/SDL2_mixer-2.0.4/include
Path for PORTMIDI: prebuilt-x86
...Library directory for PORTMIDI: prebuilt-x86/lib
...Include directory for PORTMIDI: prebuilt-x86/include
DLL for SDL2: prebuilt-x86/SDL2-2.0.10/lib/x86/SDL2.dll
DLL for SDL2_ttf: prebuilt-x86/SDL2_ttf-2.0.14/lib/x86/SDL2_ttf.dll
DLL for SDL2_image: prebuilt-x86/SDL2_image-2.0.5/lib/x86/SDL2_image.dll
DLL for SDL2_mixer: prebuilt-x86/SDL2_mixer-2.0.4/lib/x86/SDL2_mixer.dll
DLL for portmidi: prebuilt-x86/lib/portmidi.dll
Path for FREETYPE not found.
...Found include dir but no library dir in prebuilt-x86.
Path for PNG not found.
...Found include dir but no library dir in prebuilt-x86.
Path for JPEG not found.
...Found include dir but no library dir in prebuilt-x86.
DLL for freetype: prebuilt-x86/SDL2_ttf-2.0.14/lib/x86/libfreetype-6.dll
---
For help with compilation see:
https://www.pygame.org/wiki/CompileWindows
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\setup.py", line 258, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\buildconfig\config.py", line 208, in main
deps = CFG.main(**kwds)
File "C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\buildconfig\config_win.py", line 574, in main
return setup_prebuilt_sdl2(prebuilt_dir)
File "C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\buildconfig\config_win.py", line 499, in setup_prebuilt_sdl2
DEPS.configure()
File "C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\buildconfig\config_win.py", line 336, in configure
from . import vstools
File "C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\buildconfig\vstools.py", line 11, in <module>
compiler.initialize()
File "C:\Users\Operator\AppData\Local\Programs\Python\Python38-32\lib\distutils\msvc9compiler.py", line 372, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Users\Operator\PycharmProjects\Spaceinvader\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\msvc.py", line 147, in msvc9_query_vcvarsall
File "C:\Users\Operator\PycharmProjects\Spaceinvader\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\msvc.py", line 1227, in return_env
File "C:\Users\Operator\PycharmProjects\Spaceinvader\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\msvc.py", line 876, in VCIncludes
File "C:\Users\Operator\PycharmProjects\Spaceinvader\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\msvc.py", line 555, in VCInstallDir
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.1 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Operator\AppData\Local\Temp\pycharm-packaging\pygame\
pip is updated, setuptools updated
I've just installed Visual Studio and Visual Studio Build Tolls 2019 but still get this error.
I dont really know what i can do now
Maybe it must be exactly 14.1 version ?
I had the same error. I noticed this error might be as a result of either wrong python path on the system environment variables or you have defined more than one python environment on your project. Also having multiple versions of Python. To solve this problem, you can reinstall Python. However, this is not a guarantee solution, but checking your project interpreter and the Python environment should be a good place to begin.
On the project interpreter click the plus sign to set up a new environment for your project.
Option 2: check out this link https://docs.python.org/3/library/venv.html to create a new python environment for your project. But make sure you only have one version of python installed. This worked well for me.

Error compiling Cython file:word2vec_inner.pyx:1:0: 'TWE-1.gensim.models.word2vec_inner' is not a valid modu le name

setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import numpy
extensions = [
Extension("word2vec_inner", ["word2vec_inner.pyx"],
include_dirs=[numpy.get_include()])
]
setup(
name="word2vec_inner",
ext_modules=cythonize(extensions),
)
error:
Warning: Extension name 'word2vec_inner' does not match fully qualified name
'TWE-1.gensim.models.word2vec_inner' of 'word2vec_inner.pyx'
Compiling word2vec_inner.pyx because it changed.
[1/1] Cythonizing word2vec_inner.pyx
Error compiling Cython file:
------------------------------------------------------------
...
#!/usr/bin/env cython
^
------------------------------------------------------------
word2vec_inner.pyx:1:0: 'TWE-1.gensim.models.word2vec_inner' is not a valid
module name
Traceback (most recent call last):
File "D:\PyCharm 2017.3\helpers\pydev\pydevd.py", line 1668, in <module>
main()
File "D:\PyCharm 2017.3\helpers\pydev\pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\PyCharm 2017.3\helpers\pydev\pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:/pycharm/TWE/TWE-1/gensim/models/setup.py", line 11, in <module>
ext_modules=cythonize(extensions),
File "E:\Python27\lib\site-packages\cython-0.27.3-py2.7-
win32.egg\Cython\Build\Dependencies.py", line 1039, in cythonize
cythonize_one(*args)
File "E:\Python27\lib\site-packages\cython-0.27.3-py2.7-
win32.egg\Cython\Build\Dependencies.py", line 1161, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: word2vec_inner.pyx
I have install the Microsoft Visual C++ Compiler for Python 2.7 and cython, but it can't compile. It always appears this problem.
how to solve this problem? Thank you very much!
I have found the way to solve from Cython compile error "is not a valid module name"
it was the dash in the folder name. I have renamed the folder for now. But I don't know why.

Python scipy.weave not working anymore

I wrote a script a few months ago using python. In this script I use weave. This script used to work, but I retried running my program today after a few month and it doesn't work anymore. I get this error:
USAGE: facedetect.py [--cascade <cascade_fn>] [--nested-cascade <cascade_fn>] [<video_source>]
Found executable C:\strawberry\c\bin\g++.exe
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\python2.7\libs/libpython27.a when searching for -lpython27
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\python2.7\libs/python27.lib when searching for -lpython27
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\python2.7\libs\libpython27.a when searching for -lpython27
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\python2.7\libs/libpython27.a when searching for -lpython27
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\python2.7\libs/python27.lib when searching for -lpython27
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\python2.7\libs\python27.lib when searching for -lpython27
c:/strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpython27
collect2: ld returned 1 exit status
Traceback (most recent call last):
File "C:\Users\Olivier.Janssens\Documents\onlinelearning\onlinelearning\facedetect.py", line 87, in <module>
processFrame(roi,gabor)
File "C:\Users\Olivier.Janssens\Documents\onlinelearning\onlinelearning\facedetect.py", line 51, in processFrame
im = Image.fromarray(gabor.rlbp_fast_blitz(superimposed[(i*stepHeight):((i+1)*stepHeight),(j*stepWidth):((j+1)*stepWidth)]))
File "C:\Users\Olivier.Janssens\Documents\onlinelearning\onlinelearning\gaborModule.py", line 80, in rlbp_fast_blitz
weave.blitz(expr, arg_dict, check_size=0)
File "C:\python2.7\lib\site-packages\scipy\weave\blitz_tools.py", line 62, in blitz
**kw)
File "C:\python2.7\lib\site-packages\scipy\weave\inline_tools.py", line 482, in compile_function
verbose=verbose, **kw)
File "C:\python2.7\lib\site-packages\scipy\weave\ext_tools.py", line 367, in compile
verbose = verbose, **kw)
File "C:\python2.7\lib\site-packages\scipy\weave\build_tools.py", line 272, in build_extension
setup(name = module_name, ext_modules = [ext],verbose=verb)
File "C:\python2.7\lib\site-packages\numpy\distutils\core.py", line 186, in setup
return old_setup(**new_attr)
File "C:\python2.7\lib\distutils\core.py", line 169, in setup
raise SystemExit, "error: " + str(msg)
distutils.errors.CompileError: error: Command "g++ -shared c:\users\olivie~1.jan\appdata\local\temp\Olivier.Janssens\python27_intermediate\compiler_5b1f9617507e215394a4b4c2536b23c6\Release\users\olivie~1.jan\appdata\local\temp\olivier.janssens\python27_compiled\sc_24e057e16c3730b6904be220694a322419.o c:\users\olivie~1.jan\appdata\local\temp\Olivier.Janssens\python27_intermediate\compiler_5b1f9617507e215394a4b4c2536b23c6\Release\python2.7\lib\site-packages\scipy\weave\scxx\weave_imp.o -LC:\python2.7\libs -LC:\python2.7\PCbuild -lpython27 -lmsvcr90 -o c:\users\olivie~1.jan\appdata\local\temp\Olivier.Janssens\python27_compiled\sc_24e057e16c3730b6904be220694a322419.pyd" failed with exit status 1
The error states: cannot find -lpython27
this is how the folder looks like (which the program is using)
Some extra information: I have a 64 bit pc, running windows 7, python is 32 bit.
Recently my Path variable was cleared, though I've added the python path to it, maybe I need to add something here too ?
It is finding python27.lib (in the python folder) but is skipping it as incompatible most likely as it was built with Visual C++ and you are using gcc - You probably had a gcc build of python on your path - if so you need to add it back or set the linker path to include . i.e. the current directory.

Cython & Hadoopy compiling error.. any ideas on a fix?

I'm trying to run Hadoopy, but am getting a compiling error on OS X:
ImportError: Building module failed: ["CompileError: command 'llvm-gcc-4.2' failed with exit status 1\n"
I have /Developer/usr/bin in my $PATH, and am running latest version of XCode on OS X Lion 10.7. Cython was installed via easy_install.
Full output:
>>> import pyximport; pyximport.install()
>>> import hadoopy
/Users/dolan/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/hadoopy/_main.c:236:22: error: getdelim.h: No such file or directory
/Users/dolan/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/hadoopy/_main.c:236:22: error: getdelim.h: No such file or directory
/Users/dolan/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/hadoopy/_main.c: In function ‘__pyx_f_7hadoopy_5_main_11HadoopyTask_read_offset_value_text’:
/Users/dolan/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/hadoopy/_main.c:4399: warning: implicit conversion shortens 64-bit value into a 32-bit value
lipo: can't open input file: /var/folders/8b/n0j5pn_13qn_x8p2v4f848zh0000gn/T//ccC8x2Ex.out (No such file or directory)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/hadoopy/__init__.py", line 22, in <module>
from _main import run, print_doc_quit
File "/Library/Python/2.7/site-packages/Cython-0.15.1-py2.7-macosx-10.7-intel.egg/pyximport/pyximport.py", line 335, in load_module
self.pyxbuild_dir)
File "/Library/Python/2.7/site-packages/Cython-0.15.1-py2.7-macosx-10.7-intel.egg/pyximport/pyximport.py", line 183, in load_module
so_path = build_module(name, pyxfilename, pyxbuild_dir)
File "/Library/Python/2.7/site-packages/Cython-0.15.1-py2.7-macosx-10.7-intel.egg/pyximport/pyximport.py", line 167, in build_module
reload_support=pyxargs.reload_support)
File "/Library/Python/2.7/site-packages/Cython-0.15.1-py2.7-macosx-10.7-intel.egg/pyximport/pyxbuild.py", line 85, in pyx_to_dll
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/Cython-0.15.1-py2.7-macosx-10.7-intel.egg/Cython/Distutils/build_ext.py", line 135, in run
_build_ext.build_ext.run(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/Library/Python/2.7/site-packages/Cython-0.15.1-py2.7-macosx-10.7-intel.egg/Cython/Distutils/build_ext.py", line 143, in build_extensions
self.build_extension(ext)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 499, in build_extension
depends=ext.depends)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 624, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/unixccompiler.py", line 180, in _compile
raise CompileError, msg
ImportError: Building module failed: ["CompileError: command 'llvm-gcc-4.2' failed with exit status 1\n"
For me it was an installation issue and i had fixed it sometime back using below mentioned steps:
pip install argparse
git clone https://github.com/bwhite/hadoopy.git
cd hadoopy
python setup.py install
Instead of using pyximport, build the extension modules in place with python setup.py build_ext --inplace (or install for in-place development with python setup.py develop, or just a regular install via python setup.py install). For packages you almost always want to run the setup, which will properly configure the compilation environment, build, and installation process.
pyximport is good for your personal scripts if you're using Cython to speed up your code (e.g. for scientific computing). Even then you might need to bring in other libraries, and build from multiple sources. In that case, you can use a pyxbld file to set up the sources and include_dirs. For example, say you have foo.pyx, then you can place build instructions in a foo.pyxbld in the same directory. For example:
#foo.pyxbld
def make_ext(modname, pyxfilename):
from distutils.extension import Extension
return Extension(name = modname,
sources=[pyxfilename, 'bar.c'],
include_dirs=['/myinclude'] )
def make_setup_args():
return dict(script_args=["--compiler=mingw32"])
Now using foo is as simple as the following:
import pyximport
pyximport.install()
import foo
Presuming there's no compilation errors, it's virtually transparent but for the delay the first time you import the module. Subsequent imports will look for the built extension in the .pyxbld subdirectory of your home/profile directory.

Categories