Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyWinhook fails to build when installing PsychoPy 3.0.2 #2222

Closed
dvbridges opened this issue Jan 18, 2019 · 25 comments
Closed

pyWinhook fails to build when installing PsychoPy 3.0.2 #2222

dvbridges opened this issue Jan 18, 2019 · 25 comments

Comments

@dvbridges
Copy link
Contributor

dvbridges commented Jan 18, 2019

When performing developers install for PsychoPy 3.0.2 on Windows 10, the installation fails due to a pyWinhook build failure:

error: command 'swig.exe' failed: No such file or directory
@dvbridges dvbridges changed the title pyWinhook fails to install build when installing PsychoPy 3.0.2 pyWinhook fails to build when installing PsychoPy 3.0.2 Jan 18, 2019
@dvbridges
Copy link
Contributor Author

dvbridges commented Jan 18, 2019

Fixed by downloading SWIG and adding path of swig.exe to environment variables.

@hoechenberger
Copy link
Contributor

hoechenberger commented Jan 18, 2019

We previously didn't have pyHook or pyWinhook listed as package requirements probably for this reason. :\ When py(Win)hook's setup.py is called, it invokes swig to compile the C bindings.

For what it's worth, I created conda packages, so in case you fancy using a conda environment, simply do conda install -c conda-forge pywinhook.

So this is not a bug, but simply the pyWinhook devs failing to provide wheels for modern Python distributions via PyPI, so pip is forced to compile it from source.

On another side node, you now probably ended up with a non-functional pyWinhook installation, as the latest release does not support Python 3… :S My conda package, however, contains the appropriate patch.

@peircej
Copy link
Member

peircej commented Jan 18, 2019

Luckily I didn't change it in the standalone as far as I know (hoping it didn't update and break itself automatically during build)!

@hoechenberger
Copy link
Contributor

hoechenberger commented Jan 18, 2019

(This was actually part of the things that made me wonder if we shouldn't factor out the iohub deps into an extra, but there's pros and cons for both approaches)

@hoechenberger
Copy link
Contributor

hoechenberger commented Jan 18, 2019

Luckily I didn't change it in the standalone as far as I know (hoping it didn't update and break itself automatically during build)!

If you installed it manually via a wheel or exe like always, I don't think pip or setuptools would attempt to fetch / compile it again from the web, so all should be good I guess?

@hoechenberger
Copy link
Contributor

The pyWinhook maintainer has merged my PR adding Py3 support, and drafted a new release including wheels for Py 2.7 and 3.7: https://github.com/Tungsteno74/pyWinhook/releases/tag/1.6.0
Hope this will be published on PyPI soon.

@hoechenberger
Copy link
Contributor

Hey @dvbridges, the new builds are now available from PyPI: https://pypi.org/project/pyWinhook/1.6.0/#files

I will try to build and upload a Py 3.6 build as well when I have time.

I believe this closes this issue!

@dvbridges
Copy link
Contributor Author

Cool, cheers @hoechenberger.

@peircej
Copy link
Member

peircej commented Jan 25, 2019

Does this have any benefits over the pyHook that I was providing already? ie. Should I be updating the standalone to use this instead?

@hoechenberger
Copy link
Contributor

hoechenberger commented Jan 25, 2019

@peircej I don't know where you acquired pyHook for Python 3, probably from https://www.lfd.uci.edu/~gohlke/pythonlibs/? Because there are no official releases supporting Py3. My patches have added Py3 support to pyWinhook and the maintainer published fresh wheels, so installing via PyPI should now be easier (no compilation required, at least for Py 3.7, but will add 3.6 soon too).

But to answer your question, I don't think there would be much of a benefit for you to switch from pyHook to pyWinhook in standalone, as long as it works with Py3 anyway. – No benefit apart from you being able to pip install that dep for Py3 from PyPI and without compilation, that is.

@peircej
Copy link
Member

peircej commented Jan 25, 2019

Yes, I think I got it from gohlke
OK, will leave for now. thanks!

@hoechenberger
Copy link
Contributor

Py3.6 wheels now available from PyPI.

@hoechenberger
Copy link
Contributor

Meanwhile, pyWinhook 1.6.1 has been released. It contains fixes for unicode handling in window names, thereby providing an actual advantage over pyHook. Wheels for Python 2.7 and 3.7 are on PyPI, and I will publish Python 3.6 binaries tomorrow or so.

@dvbridges
Copy link
Contributor Author

dvbridges commented Mar 11, 2019

I am having problems installing PyWinHook using wheels. I get the following:

pyWinhook-1.6.0-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

The installation from the developer repo also fails because the PyWinHook build fails for reason above (swig).

@hoechenberger
Copy link
Contributor

hoechenberger commented Mar 11, 2019 via email

@dvbridges
Copy link
Contributor Author

Using Windows 10 64-bit

@hoechenberger
Copy link
Contributor

There are currently no Py3.6 wheels for pyWinhook 1.6.1 on PyPI (only for 2.7 and 3.7). I can try to publish some later tonight. In the meantime, you could use pyWinhook 1.6.0.

@dvbridges
Copy link
Contributor Author

Ah I see. No worries. I will switch to Py3.7 and go from there.

@hoechenberger
Copy link
Contributor

@dvbridges I just published a Py3.6 wheel on PyPI.

@dvbridges
Copy link
Contributor Author

Thanks @hoechenberger !

@mcprat
Copy link

mcprat commented Apr 5, 2019

@hoechenberger @peircej I just tried to install psychopy using pip on Python 2.7 and I have exactly this issue

pip printed the following
Collecting pyWinhook (from psychopy) Downloading https://files.pythonhosted.org/packages/a7/ec/f3a1190aa76f59a20ef7b8b9aebd1c60ffd0a9d4c1b5a18ce27cc1b34ae0/pyWinhook-1.6.1.zip

So is there a way I can skip this requirement, or install it another way with a different version?

EDIT:
I have never heard of wheels before but I see they are easy to install

I found the latest wheel here:
https://github.com/Tungsteno74/pyWinhook/releases/download/1.6.1/pyWinhook-1.6.1-cp27-cp27m-win_amd64.whl

@mcprat
Copy link

mcprat commented Apr 5, 2019

But I got the same thing ....

pyWinhook-1.6.1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.

I am also running Windows 10 64-bit but I have installed 32-bit python...

@mcprat
Copy link

mcprat commented Apr 5, 2019

I ended up getting swig and VC++ for python

if anyone needs the wheel for pyWinhook 1.6.1 for Python 2.7 Windows 32-bit:
https://gist.github.com/mpratt14/67a7418900566e58391b9be01fdcc9b4

@DominiqueMakowski
Copy link

DominiqueMakowski commented Jan 16, 2021

Just now I tried running pip install PsychoPy on a fresh 3.9 Python distribution, which at first failed because I didn't have the latest Microsoft BuildTools installed. After having done it, only one error remains, which seems to be related to pyWinhook.

It seems like their latest release doesn't have a 3.9 wheel... could that be the reason? is there any workaround that? Thanks!

Building wheels for collected packages: gevent, pyWinhook, dukpy
  Building wheel for gevent (PEP 517) ... done
  Created wheel for gevent: filename=gevent-21.1.0-cp39-cp39-win_amd64.whl size=1582608 sha256=e243762d198e9885343ee41c2dca6bfcef3c36e9bc3bbd055ba42e08025e5ae3
  Stored in directory: c:\users\domma\appdata\local\pip\cache\wheels\9a\dd\25\12b2609ba7c52fb7ea73455cbc9e3f3054b880d8ad35f54433
  Building wheel for pyWinhook (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\Downloads\WPy64-3902\python-3.9.0.amd64\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\domma\\AppData\\Local\\Temp\\pip-install-tcdmu6ej\\pywinhook\\setup.py'"'"'; __file__='"'"'C:\\Users\\domma\\AppData\\Local\\Temp\\pip-install-tcdmu6ej\\pywinhook\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\domma\AppData\Local\Temp\pip-wheel-dtvakb92'
       cwd: C:\Users\domma\AppData\Local\Temp\pip-install-tcdmu6ej\pywinhook\
  Complete output (16 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\pyWinhook
  copying pyWinhook\aa hook.py -> build\lib.win-amd64-3.9\pyWinhook
  copying pyWinhook\doc.py -> build\lib.win-amd64-3.9\pyWinhook
  copying pyWinhook\example.py -> build\lib.win-amd64-3.9\pyWinhook
  copying pyWinhook\HookManager.py -> build\lib.win-amd64-3.9\pyWinhook
  copying pyWinhook\__init__.py -> build\lib.win-amd64-3.9\pyWinhook
  running build_ext
  building 'pyWinhook._cpyHook' extension
  swigging pyWinhook/cpyHook.i to pyWinhook/cpyHook_wrap.c
  swig.exe -python -o pyWinhook/cpyHook_wrap.c pyWinhook/cpyHook.i
  error: command 'swig.exe' failed: None
  ----------------------------------------
  ERROR: Failed building wheel for pyWinhook
  Running setup.py clean for pyWinhook
  Building wheel for dukpy (setup.py) ... done
  Created wheel for dukpy: filename=dukpy-0.2.3-cp39-cp39-win_amd64.whl size=1290230 sha256=b31430d2747f770b3f742c971ad92460115a65de66f224ece3ae4bbdc2587d64
  Stored in directory: c:\users\domma\appdata\local\pip\cache\wheels\68\81\1c\587c6743986b3153a950f942e68a487e6c5a8873aa06680262
Successfully built gevent dukpy
Failed to build pyWinhook
Installing collected packages: pypiwin32, pyosf, opencv-python, arabic-reshaper, json-tricks, questplus, smmap, gitdb, gitpython, python-bidi, glfw, wxPython, pyglet, websocket-client, astunparse, freetype-py, pyqmix, zope.interface, zope.event, gevent, soundfile, macropy3, dukpy, javascripthon, msgpack-numpy, et-xmlfile, jdcal, openpyxl, esprima, python-gitlab, pyWinhook, PsychoPy, pyOpenSSL
    Running setup.py install for pyWinhook ... error
    ERROR: Command errored out with exit status 1:
     command: 'D:\Downloads\WPy64-3902\python-3.9.0.amd64\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\domma\\AppData\\Local\\Temp\\pip-install-tcdmu6ej\\pywinhook\\setup.py'"'"'; __file__='"'"'C:\\Users\\domma\\AppData\\Local\\Temp\\pip-install-tcdmu6ej\\pywinhook\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\domma\AppData\Local\Temp\pip-record-_5x4m_w1\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Downloads\WPy64-3902\python-3.9.0.amd64\Include\pyWinhook'
         cwd: C:\Users\domma\AppData\Local\Temp\pip-install-tcdmu6ej\pywinhook\
    Complete output (16 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    creating build\lib.win-amd64-3.9\pyWinhook
    copying pyWinhook\aa hook.py -> build\lib.win-amd64-3.9\pyWinhook
    copying pyWinhook\doc.py -> build\lib.win-amd64-3.9\pyWinhook
    copying pyWinhook\example.py -> build\lib.win-amd64-3.9\pyWinhook
    copying pyWinhook\HookManager.py -> build\lib.win-amd64-3.9\pyWinhook
    copying pyWinhook\__init__.py -> build\lib.win-amd64-3.9\pyWinhook
    running build_ext
    building 'pyWinhook._cpyHook' extension
    swigging pyWinhook/cpyHook.i to pyWinhook/cpyHook_wrap.c
    swig.exe -python -o pyWinhook/cpyHook_wrap.c pyWinhook/cpyHook.i
    error: command 'swig.exe' failed: None
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\Downloads\WPy64-3902\python-3.9.0.amd64\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\domma\\AppData\\Local\\Temp\\pip-install-tcdmu6ej\\pywinhook\\setup.py'"'"'; __file__='"'"'C:\\Users\\domma\\AppData\\Local\\Temp\\pip-install-tcdmu6ej\\pywinhook\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\domma\AppData\Local\Temp\pip-record-_5x4m_w1\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Downloads\WPy64-3902\python-3.9.0.amd64\Include\pyWinhook' Check the logs for full command output.

cdwijs pushed a commit to cdwijs/exptools2 that referenced this issue Jan 26, 2021
…rror: "command 'swig.exe' failed: No such file or directory", as suggested here:

psychopy/psychopy#2222
@csiki
Copy link

csiki commented Feb 2, 2023

hey @DominiqueMakowski, I had the same issue, just download the py39 wheel package from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywinhook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants