pyhull icon indicating copy to clipboard operation
pyhull copied to clipboard

Qhull installation trouble in windows

Open h-krishna opened this issue 8 years ago • 4 comments

Hi, I am trying to pip install qhull in a win7 environment. It failed giving and is throwing up the following error. error: command 'C:\Users\xxxxxx\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2 Any ideas?

the full message is a follows C:\Users\xxxxxxx\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc\libqhull -IC:\Python27\include -IC:\Python27\PC /Tcsrc_pyhull.c /Fobuild\temp.win32-2.7\Release\src_pyhull.obj _pyhull.c src_pyhull.c(91) : warning C4013: 'strtok_r' undefined; assuming extern returning int src_pyhull.c(91) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int' src_pyhull.c(100) : warning C4013: 'fmemopen' undefined; assuming extern returning int src_pyhull.c(100) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(101) : warning C4013: 'open_memstream' undefined; assuming extern returning int src_pyhull.c(101) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(169) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int' src_pyhull.c(180) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(181) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(255) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int' src_pyhull.c(264) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(265) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(338) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int' src_pyhull.c(347) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(348) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int' src_pyhull.c(453) : error C2143: syntax error : missing ')' before '(' src_pyhull.c(453) : error C2143: syntax error : missing ')' before '(' src_pyhull.c(453) : error C2091: function returns function src_pyhull.c(453) : error C2143: syntax error : missing ')' before 'string' src_pyhull.c(453) : error C2091: function returns function src_pyhull.c(453) : error C2143: syntax error : missing '{' before 'string' src_pyhull.c(453) : error C2059: syntax error : '<Unknown>' src_pyhull.c(453) : error C2059: syntax error : ')' src_pyhull.c(453) : error C2059: syntax error : ')'

Regards Hari

h-krishna avatar Mar 23 '16 15:03 h-krishna

I can confirm that this also shows up in Windows XP SP3: (first tried installing without realizing I needed vcpython27, hence the first install attempt shown)


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\xxxxxx>pip install pyhull
Collecting pyhull
  Downloading pyhull-1.5.6.tar.gz (298kB)
    100% |################################| 307kB 819kB/s
Requirement already satisfied (use --upgrade to upgrade): numpy in c:\python27\l
ib\site-packages (from pyhull)
Installing collected packages: pyhull
  Running setup.py install for pyhull ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools
, tokenize;__file__='c:\\docume~1\\xxxxxx\\locals~1\\temp\\pip-build-ecst0e\\pyh
ull\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().rep
lace('\r\n', '\n'), __file__, 'exec'))" install --record c:\docume~1\xxxxxx\loca
ls~1\temp\pip-csphgx-record\install-record.txt --single-version-externally-manag
ed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    creating build\lib.win32-2.7\pyhull
    copying pyhull\convex_hull.py -> build\lib.win32-2.7\pyhull
    copying pyhull\delaunay.py -> build\lib.win32-2.7\pyhull
    copying pyhull\halfspace.py -> build\lib.win32-2.7\pyhull
    copying pyhull\simplex.py -> build\lib.win32-2.7\pyhull
    copying pyhull\voronoi.py -> build\lib.win32-2.7\pyhull
    copying pyhull\__init__.py -> build\lib.win32-2.7\pyhull
    running build_ext
    building 'pyhull._pyhull' extension
    error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\
\docume~1\\xxxxxx\\locals~1\\temp\\pip-build-ecst0e\\pyhull\\setup.py';exec(comp
ile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __fi
le__, 'exec'))" install --record c:\docume~1\xxxxxx\locals~1\temp\pip-csphgx-rec
ord\install-record.txt --single-version-externally-managed --compile" failed wit
h error code 1 in c:\docume~1\xxxxxx\locals~1\temp\pip-build-ecst0e\pyhull\

C:\Documents and Settings\xxxxxx>pip install pyhull
Collecting pyhull
  Using cached pyhull-1.5.6.tar.gz
Requirement already satisfied (use --upgrade to upgrade): numpy in c:\python27\l
ib\site-packages (from pyhull)
Installing collected packages: pyhull
  Running setup.py install for pyhull ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools
, tokenize;__file__='c:\\docume~1\\xxxxxx\\locals~1\\temp\\pip-build-v8jbin\\pyh
ull\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().rep
lace('\r\n', '\n'), __file__, 'exec'))" install --record c:\docume~1\xxxxxx\loca
ls~1\temp\pip-ocy8pi-record\install-record.txt --single-version-externally-manag
ed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    creating build\lib.win32-2.7\pyhull
    copying pyhull\convex_hull.py -> build\lib.win32-2.7\pyhull
    copying pyhull\delaunay.py -> build\lib.win32-2.7\pyhull
    copying pyhull\halfspace.py -> build\lib.win32-2.7\pyhull
    copying pyhull\simplex.py -> build\lib.win32-2.7\pyhull
    copying pyhull\voronoi.py -> build\lib.win32-2.7\pyhull
    copying pyhull\__init__.py -> build\lib.win32-2.7\pyhull
    running build_ext
    building 'pyhull._pyhull' extension
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    creating build\temp.win32-2.7\Release\src
    creating build\temp.win32-2.7\Release\src\libqhull
    C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.
exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc\libqhull -Ic:\python27\include -I
c:\python27\PC /Tcsrc\_pyhull.c /Fobuild\temp.win32-2.7\Release\src\_pyhull.obj
    _pyhull.c
    src\_pyhull.c(91) : warning C4013: 'strtok_r' undefined; assuming extern ret
urning int
    src\_pyhull.c(91) : warning C4047: '=' : 'char *' differs in levels of indir
ection from 'int'
    src\_pyhull.c(100) : warning C4013: 'fmemopen' undefined; assuming extern re
turning int
    src\_pyhull.c(100) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(101) : warning C4013: 'open_memstream' undefined; assuming ext
ern returning int
    src\_pyhull.c(101) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(169) : warning C4047: '=' : 'char *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(180) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(181) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(255) : warning C4047: '=' : 'char *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(264) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(265) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(338) : warning C4047: '=' : 'char *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(347) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(348) : warning C4047: '=' : 'FILE *' differs in levels of indi
rection from 'int'
    src\_pyhull.c(453) : error C2143: syntax error : missing ')' before '('
    src\_pyhull.c(453) : error C2143: syntax error : missing ')' before '('
    src\_pyhull.c(453) : error C2091: function returns function
    src\_pyhull.c(453) : error C2143: syntax error : missing ')' before 'string'

    src\_pyhull.c(453) : error C2091: function returns function
    src\_pyhull.c(453) : error C2143: syntax error : missing '{' before 'string'

    src\_pyhull.c(453) : error C2059: syntax error : '<Unknown>'
    src\_pyhull.c(453) : error C2059: syntax error : ')'
    src\_pyhull.c(453) : error C2059: syntax error : ')'
    src\_pyhull.c(453) : error C2059: syntax error : ')'
    error: command 'C:\\Program Files\\Common Files\\Microsoft\\Visual C++ for P
ython\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\
\docume~1\\xxxxxx\\locals~1\\temp\\pip-build-v8jbin\\pyhull\\setup.py';exec(comp
ile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __fi
le__, 'exec'))" install --record c:\docume~1\xxxxxx\locals~1\temp\pip-ocy8pi-rec
ord\install-record.txt --single-version-externally-managed --compile" failed wit
h error code 1 in c:\docume~1\xxxxxx\locals~1\temp\pip-build-v8jbin\pyhull\

C:\Documents and Settings\xxxxxx>

td4u78 avatar Apr 18 '16 16:04 td4u78

It appears the fix is documented here, under "Compatibility with non-GNU compilers":

http://unixwiz.net/techtips/gnu-c-attributes.html

marcio-ao avatar Jun 15 '17 17:06 marcio-ao

I had the same problem, so I decided to start working on a patch to get pyhull working on Windows. To start, I made the change @marcio-ao suggested (thanks). This was just the tip of the iceberg though.

Next strtok_r isn't defined on Windows, so we need a substitute. I created additional #ifdef macros to change the calls to strtok for Windows machines for the major functions in _pyhull.c:

#if defined(_WIN32)
	while(token = strtok(ptr, " ")) {
		argv[argc] = token;
		argc  += 1;
	}
#else
	while(token = strtok_r(ptr, " ", &rest)) {
		argv[argc] = token;
		ptr = rest;
		argc  += 1;
	}
#endif

Next we don't have fmemopen and open_memstream on Windows. The wrappers in /src/fmemopen unfortunately don't help, because they rely on funopen, which isn't present on Windows either. This is where I'm stuck atm... If anyone knows a good way around this or wants to roll a copy of those functions, leave a reply and I can push my changes. Even any ideas or links would be appreciated. Otherwise I'll dig into this tomorrow.

NauticalMile64 avatar Jul 04 '17 00:07 NauticalMile64

Perhaps someone who is more skilled in C than I am, could have a look at this PR #15.

Ashafix avatar Sep 25 '18 17:09 Ashafix