CerebusOSS/CereLink

Failed to run setup.py on win10

Closed this issue · 21 comments

I successfully built CereLink with cmake-3.10 and visual studio 2017 but failed installing cbpy.
All outputs of running command "python setup.py install" are listed below:
running install
running bdist_egg
running egg_info
writing cerebus.egg-info\PKG-INFO
writing dependency_links to cerebus.egg-info\dependency_links.txt
writing requirements to cerebus.egg-info\requires.txt
writing top-level names to cerebus.egg-info\top_level.txt
reading manifest file 'cerebus.egg-info\SOURCES.txt'
writing manifest file 'cerebus.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
skipping 'cerebus\cbpy.cpp' Cython extension (up-to-date)
building 'cerebus.cbpy' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Python36\lib\site-packages\numpy\core\include" -ID:\git_repo\CereLink\dist\include -ID:\git_repo\CereLink\compat -ID:\Qt\5.9.2\msvc2017_64\include "-IC:\Program Files\Python36\include" "-IC:\Program Files\Python36\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" /EHsc /Tpcerebus\cbpy.cpp /Fobuild\temp.win-amd64-3.6\Release\cerebus\cbpy.obj
cbpy.cpp
cerebus\cbpy.cpp(443): error C2371: “uint32_t”: redefinition; different basic types
D:\git_repo\CereLink\compat\stdint.h(392): note: see declaration of 'uint32_t'
D:\git_repo\CereLink\dist\include\cbhwlib.h(2717): warning C4244: “=”: conversion from 'uint32_t' to 'uint16_t', possible loss of data
D:\git_repo\CereLink\dist\include\cbhwlib.h(2838): warning C4244: “=”: conversion from 'uint32_t' to 'uint16_t', possible loss of data
D:\git_repo\CereLink\dist\include\cbhwlib.h(2843): warning C4244: “=”: conversion from 'uint32_t' to 'uint16_t', possible loss of data
c:\program files\python36\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
cerebus\cbpy.cpp(10511): warning C4244: “argument”: conversion from 'uint32_t' to 'uint16_t', possible loss of data
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64\cl.exe' failed with exit status 2

Here is the error:

cerebus\cbpy.cpp(443): error C2371: “uint32_t”: redefinition; different basic types

I believe this error is fixed in my 7.0 branch, but that won't help you unless your NSP is running the latest firmware. Is it?

I merged @cboulay's PR please try again

I checkout to branch Cerelink 7.0, but the error seems still exist... By the way, I successfully installed python package in master on Ubuntu16.04. Why that error won't occur on Ubuntu?

I'll give it a try with MSVC 2017 tomorrow.

I found in file "CereLink/compat/stdint.h(line 392)" the uint32_t type was defined as unsigned long, while in my Cython's stdin.pxd uint32_t was defined as unsigned int. Does it relate to the error?

I used stdin.h of vc14 and successfully built the python package. But sadly I encountered another error. When I import cerebus.cbpy, it fails with missing DLL message. I have tried to add all the directories contain .dll file to path and still didn't work...

Sorry I didn't have a chance to get to this today. What versions of Python and Cython are you using?

By the way, I use MSVC 2015 and Python 3.6 and it works for me (sorry I don't know the version of Cython right now). You can try that while you wait for me to fix the problem with msvc 2017.

Sorry, one more thing I just noticed...
The pull request that @dashesy merged recently was a PR into Cerelink7.0, not into master. You'll notice that the Cerelink7.0 branch does not have the stdint.h file that is causing you problems, so your checkout of that branch seems unsuccessful.

I use python3.6.3 and cython 0.27.3. Thank you a lot and I tried your 7.0 branch just now. The build worked but I encountered another problem that when I import cerebus.cbpy, a dll missing error occurs. Do I miss anything significant?

I use command "dumpbin.exe cbpy.cp36-win_amd64.pyd /IMPORTS | find ".dll"" to check the dependency, the outputs are listed below :
WS2_32.dll
WINMM.dll
KERNEL32.dll
Qt5Core.dll
python36.dll
VCRUNTIME140.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-conio-l1-1-0.dll
I checked carefully and made sure that they are all in path...
Do I still miss something?

I just ran through the steps and I was able to get the CereLink7.0 branch working for me without modification.

  • Open an administrator command prompt
  • From the CereLink\build directory: cmake .. -G "Visual Studio 15 2017 Win64" -DQt5_DIR="C:\Qt\5.9.3\msvc2017_64\lib\cmake\Qt5"
  • Open CBSDK.sln in MSVC 2017
  • Build Release cbsdk-static
  • Close MSVC 2017
  • In the terminal, change back to the parent CereLink directory containing setup.py
  • SET QTDIR=C:\Qt\5.9.3\msvc2017_64
  • pip3 install .

When you test it, e.g. with ipython, make sure your working directory is not the CereLink directory, because then importing cerebus will attempt to import the contents of the CereLink\cerebus directory, and that's not what you want. So cd .. a couple times to get out of there before running Ipython.

I'm sorry but I still get the dll not found error. Does 32-bit or 64-bit python make any difference here?

Yes. The DLL build with MSVC (and its Qt dependency) and Python all have to be on the same architecture. I've never tested this on 32-bit.

Thank you a lot. I finally succeed by copying Qt5Core.dll into the cerebus site-package folder. But I am really confused because I'm certain that Qt5 bin is in the system path...

Hmm... I don't have Qt5 on my system path, and I don't have Qt5Core.dll in my site-package folder. But I do have PyQt5 (and pyqtgraph) installed so I wonder if they make the requested dlls available to Python, though that seems unlikely. The only file of any substance that exists in my site-packages\cerebus folder is cbpy.cp36-win_amd64.pyd.

I have installed pyqt5 before and just now I installed pyqtgraph... However, when I delete the dll in the folder, I got the dll not found error again. The system will certainly search for dlls in the path so I don't think the current situation make any sense... It's really frustrating...

Can you try removing any Qt-related directories from your system and user PATH variables?

No, it doesn't work anyway.

I think I finally figure it out after such a long time. It is because I haven't add the directory contains Qt5Core.dll to $PYTHONPAH. After adding python*/Lib to pythonpath cbpy can finally work without copying Qt5Core.dll to the cerebus directory...

For future issue-searchers, I think that the solution indicates a problem specific to this user's configuration/environment. In most cases it should not be necessary to modify PYTHONPATH. I've used cerebus on ~ 5 different PCs, Windows Mac and Ubuntu, and never once had to alter PYTHONPATH.