Using RPi.GPIO with django











up vote
-1
down vote

favorite












I have django project set on my pc and copy of that project on Raspberry pi 3. I deploy changes through pyCharm to raspi. Raspberry is my server where I host my website. I wanted to play with led light through web app. In my app I've imported import RPI.GPIO as GPIO but after server run there was ImportError: No module named 'RPi'. I've managed to install only gpio on pc (No matching distribution found for RPi), but there is still ImportError : No module named 'gpio'. Here is my code in views.py



import gpio
LED_PIN = 18
def turnOn(request):
gpio.setmode(gpio.BOARD)
gpio.output(LED_PIN, 1)
return HttpResponse('')


Is there any possibility to use RPi.GPIO in django on pc?










share|improve this question


















  • 2




    You cannot get RPi.GPIO on your pc, there are different io connections. However, if you deploy the code to your raspberry pi and run you can use RPi.GPIO.
    – Arnav Chawla
    Nov 10 at 22:25















up vote
-1
down vote

favorite












I have django project set on my pc and copy of that project on Raspberry pi 3. I deploy changes through pyCharm to raspi. Raspberry is my server where I host my website. I wanted to play with led light through web app. In my app I've imported import RPI.GPIO as GPIO but after server run there was ImportError: No module named 'RPi'. I've managed to install only gpio on pc (No matching distribution found for RPi), but there is still ImportError : No module named 'gpio'. Here is my code in views.py



import gpio
LED_PIN = 18
def turnOn(request):
gpio.setmode(gpio.BOARD)
gpio.output(LED_PIN, 1)
return HttpResponse('')


Is there any possibility to use RPi.GPIO in django on pc?










share|improve this question


















  • 2




    You cannot get RPi.GPIO on your pc, there are different io connections. However, if you deploy the code to your raspberry pi and run you can use RPi.GPIO.
    – Arnav Chawla
    Nov 10 at 22:25













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have django project set on my pc and copy of that project on Raspberry pi 3. I deploy changes through pyCharm to raspi. Raspberry is my server where I host my website. I wanted to play with led light through web app. In my app I've imported import RPI.GPIO as GPIO but after server run there was ImportError: No module named 'RPi'. I've managed to install only gpio on pc (No matching distribution found for RPi), but there is still ImportError : No module named 'gpio'. Here is my code in views.py



import gpio
LED_PIN = 18
def turnOn(request):
gpio.setmode(gpio.BOARD)
gpio.output(LED_PIN, 1)
return HttpResponse('')


Is there any possibility to use RPi.GPIO in django on pc?










share|improve this question













I have django project set on my pc and copy of that project on Raspberry pi 3. I deploy changes through pyCharm to raspi. Raspberry is my server where I host my website. I wanted to play with led light through web app. In my app I've imported import RPI.GPIO as GPIO but after server run there was ImportError: No module named 'RPi'. I've managed to install only gpio on pc (No matching distribution found for RPi), but there is still ImportError : No module named 'gpio'. Here is my code in views.py



import gpio
LED_PIN = 18
def turnOn(request):
gpio.setmode(gpio.BOARD)
gpio.output(LED_PIN, 1)
return HttpResponse('')


Is there any possibility to use RPi.GPIO in django on pc?







python django raspberry-pi gpio remote-control






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 22:11









Aleksandra Skoczypiec

415




415








  • 2




    You cannot get RPi.GPIO on your pc, there are different io connections. However, if you deploy the code to your raspberry pi and run you can use RPi.GPIO.
    – Arnav Chawla
    Nov 10 at 22:25














  • 2




    You cannot get RPi.GPIO on your pc, there are different io connections. However, if you deploy the code to your raspberry pi and run you can use RPi.GPIO.
    – Arnav Chawla
    Nov 10 at 22:25








2




2




You cannot get RPi.GPIO on your pc, there are different io connections. However, if you deploy the code to your raspberry pi and run you can use RPi.GPIO.
– Arnav Chawla
Nov 10 at 22:25




You cannot get RPi.GPIO on your pc, there are different io connections. However, if you deploy the code to your raspberry pi and run you can use RPi.GPIO.
– Arnav Chawla
Nov 10 at 22:25












2 Answers
2






active

oldest

votes

















up vote
0
down vote













RPi.GPIO is Raspberry-specific and you really cannot use it on your computer - it even has no GPIO ports. You should deploy your code to RPi and use it there.






share|improve this answer




























    up vote
    0
    down vote













    I found a solution. With help of wiringPi and subprocess I could execute command.



    def turnOn(request):
    subprocess.call(['gpio', '-g', 'mode', '3', 'out'])
    subprocess.call(['gpio', '-g', 'write', '3', '1'])
    return HttpResponse('')





    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243937%2fusing-rpi-gpio-with-django%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      RPi.GPIO is Raspberry-specific and you really cannot use it on your computer - it even has no GPIO ports. You should deploy your code to RPi and use it there.






      share|improve this answer

























        up vote
        0
        down vote













        RPi.GPIO is Raspberry-specific and you really cannot use it on your computer - it even has no GPIO ports. You should deploy your code to RPi and use it there.






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          RPi.GPIO is Raspberry-specific and you really cannot use it on your computer - it even has no GPIO ports. You should deploy your code to RPi and use it there.






          share|improve this answer












          RPi.GPIO is Raspberry-specific and you really cannot use it on your computer - it even has no GPIO ports. You should deploy your code to RPi and use it there.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 23:19









          Martin Urbanec

          2818




          2818
























              up vote
              0
              down vote













              I found a solution. With help of wiringPi and subprocess I could execute command.



              def turnOn(request):
              subprocess.call(['gpio', '-g', 'mode', '3', 'out'])
              subprocess.call(['gpio', '-g', 'write', '3', '1'])
              return HttpResponse('')





              share|improve this answer

























                up vote
                0
                down vote













                I found a solution. With help of wiringPi and subprocess I could execute command.



                def turnOn(request):
                subprocess.call(['gpio', '-g', 'mode', '3', 'out'])
                subprocess.call(['gpio', '-g', 'write', '3', '1'])
                return HttpResponse('')





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  I found a solution. With help of wiringPi and subprocess I could execute command.



                  def turnOn(request):
                  subprocess.call(['gpio', '-g', 'mode', '3', 'out'])
                  subprocess.call(['gpio', '-g', 'write', '3', '1'])
                  return HttpResponse('')





                  share|improve this answer












                  I found a solution. With help of wiringPi and subprocess I could execute command.



                  def turnOn(request):
                  subprocess.call(['gpio', '-g', 'mode', '3', 'out'])
                  subprocess.call(['gpio', '-g', 'write', '3', '1'])
                  return HttpResponse('')






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 12 at 14:47









                  Aleksandra Skoczypiec

                  415




                  415






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243937%2fusing-rpi-gpio-with-django%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine