简体   繁体   中英

Q: Install pyHook with pip for Python 2.7 on Windows

My computer runs on Windows 7 (x64) and I installed Anaconda 2 and Anaconda 3 both in 32 bit version, to be able to use Python 2.7 or 3.5 depending on my projects. I'm trying to install pyHook for Python 2.7 and I'm struggling.

I tried with pip and the first windows installer of this page:

pip install C:\\Users\\...\\Downloads\\pyHook-1.5.1-cp27-cp27m-win32.whl

but I get the following error:

pyHook-1.5.1-cp27-cp27m-win32.whl is not a supported wheel on this platform.

Just to be sure I checked which version of pip is running and it turns out it is the one of Python 3. So I had a look on the web and found this and this solutions. I tried them:

pip-2.7 pip install pyhook

py -2.7 pip install C:\\Users\\...\\Downloads\\Downloads\\pyHook-1.5.1-cp27-cp27m-win32.whl

But apparently python doesn't recognized any of these comands:

'pip-27' is not recognized as an internal or external command...

C:\\Program Files (x86)\\Anaconda2\\python.exe: can't open file 'pip': [Errno 2] No such file or directory

I must admit that I'm out of idea. Has anyone already encountered this problem?

'pip' command is under "C:\\Python27\\Scripts" folder.So you should go to that folder and execute 'pip.exe' command. Also, it is nice to set below paths to our system variable 'PATH ' in windows OS.

C:\Python27\
C:\Python27\Scripts

By setting above paths in PATH variable , 'pip' and 'python' command can be executed directory on command prompt.

pip --version
pip 7.0.1 from C:\Python27\lib\site-packages (python 2.7)
python --version
Python 2.7.10

Now, 2nd issue 'pyHook-1.5.1-cp27-cp27m- win32 .whl is not a supported wheel on this platform.' It seems, you have get the whl file for 64 bit (can be found at https://www.lfd.uci.edu/~gohlke/pythonlibs/ ). Use below whl file or download the correct whl file for pyHook and install it.

C:\Python27\Scripts\pip.exe install pyHook‑1.5.1‑cp27‑none‑win_amd64.whl

Thanks to @Jitendra answer I managed to solve my problem.

My PATH already contains the directories where Python and pip are located. They are a bit different since Python is installed with Anaconda:

C:\\Program Files (x86)\\Anaconda2

C:\\Program Files (x86)\\Anaconda2\\Scripts

I installed pyHook by going in the \\Anaconda2\\Script directory and using the .whl file:

cd C:\\Program Files (x86)\\Anaconda2\\Scripts

pip install C:\\Users\\...\\Downloads\\pyHook-1.5.1-cp27-cp27m-win32.whl

Well, Windows is as stinky as it can get. I spent my good many hours over this. Finally this is what worked. For Python 2, I had to install 2 packages in same folder 2.7.6 and 2.7.14rc1

It is not a solution, just a work-around which worked. I hope i never get to work on windows ever again.

just another angle to look at it from.

I use "py" to have python 2.7 and 3.5 on my system, so I sometimes run into similar issues.

If you can confidently envoke python 2 itself, start up the interpreter and then you access pip and perform the install programmatically:

import pip

#download the .whl file by your own method and get its path
wheel_location = r'C:\Users\...\Downloads\pyHook-1.5.1-cp27-cp27m-win32.whl'

#pip.main(['list', 'of', 'pip', 'commands'])
try:
    pip.main(['install', wheel_location])
except ImportError as e:
    print("Problem with installing {}, reason:{}".format(wheel_location, e)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM