Python version incorrectly identified

2019-06-25 09:39发布

问题:

I have begun using pyqtdeploy for using pyqt and making cross platform apps. Unfortunately, When I actually try to launch it, I get the error:

Fatal error in launcher: Unable to create process using C:\Python34\python.exe C:\Python34\pyqtdeploy

I read this earlier question, but python3 -m pip install pyqtdeploy --upgrade was also giving me a similar error.

Going in with a hex editor seems rather risky and extreme? Is there another explanation/solution for this? My path to python34 doesn't have spaces in it, so that couldn't be the problem. Could it be my Python27 install?

EDIT:

I tried py -m pip install pyqtdeploy --upgrade (Thanks @Saurabh Randhawa), but that didn't work. The command failed with the following:

Downloading/unpacking pyqtdeploy
  Running setup.py (path:c:\users\<username>\appdata\local\temp\pip_build_IronManMark20\pyqtdeploy\setup.py) egg_info for package pyqtdeploy
    pyqtdeploy requires Python v3.2 or later
    Complete output from command python setup.py egg_info:
    pyqtdeploy requires Python v3.2 or later

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in c:\users\<username>\appdata\local\temp\pip_build_IronManMark20\pyqtdeploy
Storing debug log for failure in C:\Users\<username>\pip\pip.log

And pip.log:

------------------------------------------------------------
C:\Python27\lib\site-packages\pip\__main__.py run on 04/26/15 12:28:05
Downloading/unpacking pyqtdeploy
  Getting page https://pypi.python.org/simple/pyqtdeploy/
  URLs to search for versions for pyqtdeploy:
  * https://pypi.python.org/simple/pyqtdeploy/
  Analyzing links from page https://pypi.python.org/simple/pyqtdeploy/
    Skipping https://pypi.python.org/packages/py3/p/pyqtdeploy/pyqtdeploy-0.10-py3-none-any.whl#md5=43c6bd10b5a839be52b5729aedcc776b (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py3/p/pyqtdeploy/pyqtdeploy-0.9-py3-none-any.whl#md5=7ae0f11468cfba8ad42a600b69016db0 (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py3/p/pyqtdeploy/pyqtdeploy-1.0-py3-none-any.whl#md5=8107db271085ca07000017e46f8c37ac (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.1-py34-none-any.whl#md5=f0a41a4a5fd56e38f8e616af46bf1b68 (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.2-py34-none-any.whl#md5=4d3ff35c86c6f58eb20230fbf0082723 (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.3-py34-none-any.whl#md5=5b0b3954113a91002bcf7067a62d72eb (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.4-py34-none-any.whl#md5=2c8e0a14c914613c7913e90a7b0f9682 (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.5-py34-none-any.whl#md5=58419ff7d8825628f566143c8786121c (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.6-py34-none-any.whl#md5=59cc0a08c1408703a94f2209c43928e9 (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.7-py34-none-any.whl#md5=d4f69bd23c2b4dcf0f29a86bda9c6ed0 (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/py34/p/pyqtdeploy/pyqtdeploy-0.8-py34-none-any.whl#md5=b653cdc694173741de350287a232643a (from https://pypi.python.org/simple/pyqtdeploy/) because it is not compatible with this Python
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.1.tar.gz#md5=32857d8029c8a5ca2b10024abb980b87 (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.1
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.10.tar.gz#md5=a84a90faf2327a6cb54117fec5fa16fc (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.10
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.2.tar.gz#md5=2c9bf2fe08ba23c6a1be0838e1ec47aa (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.2
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.3.tar.gz#md5=ef26df0bf3cda02de2dafb923bfe6847 (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.3
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.4.tar.gz#md5=5b6b989d4b21cd3b05a179006298e755 (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.4
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.5.tar.gz#md5=3ac7526e302e77cfdae057018a2af600 (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.5
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.6.tar.gz#md5=e4cf32765d9c9aa6e04fcea12fcb4bc0 (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.6
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.7.tar.gz#md5=bb3b5c0fa0c3ddfaea287e7438ede58c (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.7
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.8.tar.gz#md5=b3d6faf50be4784ec1a1f0709c3acc27 (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.8
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-0.9.tar.gz#md5=da00b401948436c915245084df93222f (from https://pypi.python.org/simple/pyqtdeploy/), version: 0.9
    Found link https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-1.0.tar.gz#md5=97f852bd368acd739228dad7aae46c44 (from https://pypi.python.org/simple/pyqtdeploy/), version: 1.0
  Using version 1.0 (newest of versions: 1.0, 0.10, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1)
  Downloading from URL https://pypi.python.org/packages/source/p/pyqtdeploy/pyqtdeploy-1.0.tar.gz#md5=97f852bd368acd739228dad7aae46c44 (from https://pypi.python.org/simple/pyqtdeploy/)
  Running setup.py (path:c:\users\<username>\appdata\local\temp\pip_build_IronManMark20\pyqtdeploy\setup.py) egg_info for package pyqtdeploy
    pyqtdeploy requires Python v3.2 or later
    Complete output from command python setup.py egg_info:
    pyqtdeploy requires Python v3.2 or later

----------------------------------------
Cleaning up...
  Removing temporary dir c:\users\<username>\appdata\local\temp\pip_build_IronManMark20...
Command python setup.py egg_info failed with error code 1 in c:\users\<username>\appdata\local\temp\pip_build_IronManMark20\pyqtdeploy
Exception information:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "C:\Python27\lib\site-packages\pip\req.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "C:\Python27\lib\site-packages\pip\util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in c:\users\<username>\appdata\local\temp\pip_build_IronManMark20\pyqtdeploy

I know that I am running Python 3.4.2. What could be causing this? It says the version is wrong, but it obviously isn't.

EDIT2: Okay, this is really weird, I tried running the command again (without trying any of the solutions!), and it worked. The working code: python3 -m pip install pyqtdeploy --upgrade. Why would this change without me changing anything?

While I am editing, I am running 32bit Python (both versions) on 64 bit windows.

回答1:

This line from the log :

C:\Python27\lib\site-packages\pip\__main__.py

proves that you have a Python2.7 installation in addition to the 3.4 one and ... that is the one used by pip !

As suggested by Python 3.4 manual, you could try to use explicitely py -3 :

py -3   -m pip install pyqtdeploy --upgrade  # default Python 3
py -3.4 -m pip install pyqtdeploy --upgrade  # specifically Python 3.4

The magic of py is to find and launch to correct Python version when you have more than one installed (what seems to be your case).



回答2:

  • Start command prompt as an administrator

    1. Click Start, click All Programs, and then click Accessories.
    2. Right-click Command prompt, and then click Run as administrator.
    3. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  • Type py -m pip install pyqtdeploy --upgrade



回答3:

Python installation (at least under windows) sets up PYTHONPATH environment variable, for example:

C:\Users\vyktor>SET PYTHONPATH
PYTHONPATH=C:\Python32\Lib;C:\Python32\DLLs;C:\Python32\Lib\lib-tk

So you probably have PYTHONPATH set to 27 version...

Try setting up value by hand:

C:\Users\vyktor>SET PYTHONPATH=C:\Python34\Lib

C:\Users\vytkor>SET PYTHONPATH
PYTHONPATH=C:\Python34\Lib

And re-execute your scripts, it should work fine.