Importing RPi.GPIO into a Python Project within Visual Studio

邮差的信 提交于 2020-01-03 05:15:42

问题


I just recently came across PTVS which provides a pretty killer environment for Python development. I was most excited when I found this because it seems that it could provide a clean and user friendly environment to develop and debug Raspberry Pi programs within Visual Studio. As stated by the developers,

Python Tools already provides a number of facilities to debug apps launched from the IDE itself, as well as attaching to existing Python processes on both local and remote machines. However, these all only work if the process being debugged is running on a Windows PC, and attaching remotely also requires the Visual Studio Remote Debugging Monitor (MSVSMon) to be running on the remote PC. For situations when your app is running on a different operating system, such as Linux or OS X, or when you do not have permissions to install or run MSVSMon on a Windows machine, Python Tools 2.0 adds an alternative remote debugging option that does not require any separate processes, and runs on any OS capable of running Python itself.

So as I understand, and correct me if I'm wrong, but this tool would allow a developer to develop and debug Python applications remotely through Visual Studio on the Raspberry Pi itself.

Even if this isn't the case, it seems that the support for this tool is pretty solid, and I really excited to see all of the features that it has to offer. With that being said, I'm trying to move my Pi development along, but I am having trouble installing the RPi.GPIO Python module. I'm not too familiar with installing Python modules through Windows.

What I've done so far:

  1. Installed distribute
  2. Installed pip
  3. Added C:\Python 3.3\Scripts to my Path environment variable.

So in the Scripts folder I have:

  • easy_install.exe
  • easy_install-3.3.exe
  • pip.exe
  • pip-3.3.exe

Along with the executables are the corresponding python scrips (pip-script.py, pip-3.3-script.py, etc..). What do I need to do to install extra Python modules and use them within the PTVS environment?


回答1:


To install extra modules you can either just run pip / easy_install from an elevated command line giving them a module name to install. Inside of VS you can go to the interpreters window (Ctrl-K-` by default, or View->Other Windows->Python Environments) and regenerate the completion database so you get intellisense against the new modules.

You could also use virtual environments to build up isolated environments with the individual packages. There you'd create a new environment from within VS and could install packages into them. Same deal with the environments window here, you can see the status of the database and force it to refresh. The nice thing about virtual envs is you can have different versions of various packages and dependencies in different environments and can just delete the directory to get rid of it all.



来源:https://stackoverflow.com/questions/19075635/importing-rpi-gpio-into-a-python-project-within-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!