Xmindz
Xmindz

Reputation: 1282

Error installing python package with Visual Studio 2015

I'm new to Python and trying to start with Python in Visual Studio 2015 as I'm familiar with VS. I could successfully create a sample program but when I'm trying to install a package rpi.gpio using pip, it gives me the following error. I'm using Python 2.7 64bit and Visual Studio 2015. Could anyone please help?

----- Installing 'rpi.gpio' -----
You are using pip version 7.0.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting rpi.gpio
  Using cached RPi.GPIO-0.5.11.tar.gz
Installing collected packages: rpi.gpio
  Running setup.py install for rpi.gpio
    Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\30201610\\appdata\\local\\temp\\pip-build-6yfuyd\\rpi.gpio\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\30201610\appdata\local\temp\pip-ovjyww-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\RPi
    copying RPi\__init__.py -> build\lib.win-amd64-2.7\RPi
    running build_ext
    building 'RPi.GPIO' extension
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    creating build\temp.win-amd64-2.7\Release\source
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcsource/py_gpio.c /Fobuild\temp.win-amd64-2.7\Release\source/py_gpio.obj
    py_gpio.c
    source/py_gpio.c(81): error C2143: syntax error: missing ';' before '{'
    source/py_gpio.c(109): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(113): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(194): error C2143: syntax error: missing ';' before '{'
    source/py_gpio.c(218): warning C4047: 'return': 'PyObject *' differs in levels of indirection from 'int'
    source/py_gpio.c(270): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(272): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(326): error C2373: 'output': redefinition; different type modifiers
    c:\users\30201610\appdata\local\temp\pip-build-6yfuyd\rpi.gpio\source\constants.h(29): note: see declaration of 'output'
    source/py_gpio.c(326): error C2143: syntax error: missing ';' before '{'
    source/py_gpio.c(340): warning C4047: 'return': 'PyObject *' differs in levels of indirection from 'int'
    source/py_gpio.c(387): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(389): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(391): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    source/py_gpio.c(393): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\30201610\\appdata\\local\\temp\\pip-build-6yfuyd\\rpi.gpio\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\30201610\appdata\local\temp\pip-ovjyww-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\30201610\appdata\local\temp\pip-build-6yfuyd\rpi.gpio
----- Failed to install 'rpi.gpio' -----

Upvotes: 4

Views: 1389

Answers (2)

Peter Adam
Peter Adam

Reputation: 89

You probably not needed the rpi.gpio package to remote access the pins of the Pi. Pin factory is missing if no remote pigpio server configured via the PIGPIO_ADDR environment variable, so it falls back to localhost, where, well, there is nothing.

  • apt install pigpio to the Pi
  • On the Interfaces tab of the Pi Configuration enable remote GPIO
  • start the daemon with sudo pigpiod
  • pip install the gpiozero and pigpio packages to the Windows machine
  • set the PIGPIO_ADDR environment variable like SET PIGPIO_ADDR=192.168.1.3
  • start your Python app on the PC while the Pi is accessible via the network.

This way I was able to use exactly the same code on my PC as on the Pi.

If you use ANSI control sequences, consider using the new MS Windows Terminal from te store

More details, alternatives, remote OSs: https://gpiozero.readthedocs.io/en/stable/remote_gpio.html

Upvotes: 0

Tyhal
Tyhal

Reputation: 789

relevant sourceforge issue

RPi.GPIO is designed to run on a Raspberry Pi running Linux only. - Ben Croston (Maintainer)

Upvotes: 2

Related Questions