简体   繁体   中英

why does installing pygobject is giving error and cannot install further

Im getting below error when installing PyGObject using pip on windows python version 2.7.18

pip install PyGObject


  ERROR: Command errored out with exit status 1:
   command: 'c:\python27\python.exe' 'c:\python27\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'c:\users\test\appdata\local\temp\pip-build-env-9
qeux4\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo
       cwd: None
  Complete output (35 lines):
  DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support
 for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
  Collecting setuptools
    Using cached setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
  Collecting wheel
    Using cached wheel-0.35.1-py2.py3-none-any.whl (33 kB)
  Collecting pycairo
    Using cached pycairo-1.18.2.tar.gz (200 kB)
  Using legacy 'setup.py install' for pycairo, since package 'wheel' is not installed.
  Installing collected packages: setuptools, wheel, pycairo
      Running setup.py install for pycairo: started
      Running setup.py install for pycairo: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: 'c:\python27\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\test\\appdata\\local\\temp\\pip-install-cp90gz\\pycairo\
\setup.py'"'"'; __file__='"'"'c:\\users\\test\\appdata\\local\\temp\\pip-install-cp90gz\\pycairo\\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\test\appdata\local\temp\pip-record-n
nbplv\install-record.txt' --single-version-externally-managed --prefix 'c:\users\test\appdata\local\temp\pip-build-env-9qeux4\overlay' --compile --install-headers 'c:\u
sers\test\appdata\local\temp\pip-build-env-9qeux4\overlay\Include\pycairo'
           cwd: c:\users\test\appdata\local\temp\pip-install-cp90gz\pycairo\
      Complete output (18 lines):
      running install
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-2.7
      creating build\lib.win-amd64-2.7\cairo
      copying cairo\__init__.py -> build\lib.win-amd64-2.7\cairo
      copying cairo\__init__.pyi -> build\lib.win-amd64-2.7\cairo
      copying cairo\py.typed -> build\lib.win-amd64-2.7\cairo
      running build_ext
      building 'cairo._cairo' extension
      creating build\temp.win-amd64-2.7
      creating build\temp.win-amd64-2.7\Release
      creating build\temp.win-amd64-2.7\Release\cairo
      C:\Users\test\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DPYCAIRO_VERSION_MAJOR=1
 -DPYCAIRO_VERSION_MINOR=18 -DPYCAIRO_VERSION_MICRO=2 -Ic:\python27\include -Ic:\python27\PC /Tccairo/device.c /Fobuild\temp.win-amd64-2.7\Release\cairo/device.obj
      device.c
      c:\users\test\appdata\local\temp\pip-install-cp90gz\pycairo\cairo\pycairo.h(37) : fatal error C1083: Cannot open include file: 'cairo.h': No such file or director
y
      error: command 'C:\\Users\\test\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
      ----------------------------------------
  ERROR: Command errored out with exit status 1: 'c:\python27\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\test\\appdata\\local\\t
emp\\pip-install-cp90gz\\pycairo\\setup.py'"'"'; __file__='"'"'c:\\users\\test\\appdata\\local\\temp\\pip-install-cp90gz\\pycairo\\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\tes
t\appdata\local\temp\pip-record-nnbplv\install-record.txt' --single-version-externally-managed --prefix 'c:\users\test\appdata\local\temp\pip-build-env-9qeux4\overlay'
--compile --install-headers 'c:\users\test\appdata\local\temp\pip-build-env-9qeux4\overlay\Include\pycairo' Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python27\python.exe' 'c:\python27\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'c:\users\test
\appdata\local\temp\pip-build-env-9qeux4\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simplehttps://pypi.org/simple -- setuptools wheel pycai
ro Check the logs for full command output.

You won't be able to install PyGObject like that because MS Visual C is not going to be able to compile it.

If you follow the PyGObject Getting Started in Windows instructions, you should be able to install PyGObject in Windows using MSYS2.

  1. Go to http://www.msys2.org/ and download the x86_64 installer
  2. Follow the instructions on the page for setting up the basic environment
  3. Run C:\\msys64\\mingw64.exe - a terminal window should pop up
  4. Execute pacman -Suy
  5. Execute pacman -S mingw-w64-x86_64-gtk3 mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-gobject
  6. To test that GTK 3 is working you can run gtk3-demo
  7. Copy the hello.py script you created to C:\\msys64\\home\\<username>
  8. In the mingw64 terminal execute python3 hello.py - a window should appear.

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