Import requests not working. Getting "ImportError: No module named requests"

2,217 views
Skip to first unread message

Gerry Manley

unread,
Jan 1, 2014, 4:47:14 AM1/1/14
to web...@googlegroups.com
Hi All,

I would like to use requests to control functions in my Grandstream cameras, example when I activate an input - manually trigger a button or by a timer, I want to send a requests.get command to my grandstream camera to turn On MotionDetect:

"r = requests.get('http://192.168.20.30/goform/motiondetect?cmd=set&md.active.enable=1', auth=('username' , 'password'))

I have correctly installed requests and tested my requirement with a separate py script and it works.

But when I add the code to my webiopi script.py and start the debug, I see this error: ImportError: No module named requests

I believe my problem lies in the /home/pi/WebIOPI-0.6.0/python/webiopi/utils.py as here it shows all the import modules.

I added "import requests" but cannot save the file as it's protected.

Decided not to go further until I got some expert help

/Gerry


Eric PTAK

unread,
Jan 3, 2014, 1:29:14 PM1/3/14
to web...@googlegroups.com
You need to install request for the python version used by webiopi 
see in /etc/init.d/webiopi
if python3 is used, you have to use it to install your libraries.
then you need to import your libraries in your custom script, not in webiopi sources.


--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Shane

unread,
Jan 6, 2014, 4:01:39 AM1/6/14
to web...@googlegroups.com
I think I'm having the same problem- I'm running pyusb and importing usb.core to run a Maplin Robot arm. I want to build a web based GUI for it with webiopi.
The test script works and imports usb.core but I get the same no module named usb.core when my custom script is called.

Could you be a bit more detailed about how we go about fixing this- I don't really understand the answer.

Thanks

Shane 

Eric PTAK

unread,
Jan 6, 2014, 5:42:50 AM1/6/14
to web...@googlegroups.com
how did you installed pyusb ?


--

Shane

unread,
Jan 7, 2014, 2:11:40 AM1/7/14
to web...@googlegroups.com
If  I remember correctly it was from the instructions on this page:

ie made a dir pyusb in my home directory and git cloned
sudo python setup.py install

I assume that this is a path problem is it?
I have the correct portable shebang line
#! /usr/bin/env python
at the top of the python script.

Any help would be appreciated

Thanks

Shane

Gerry Manley

unread,
Jan 7, 2014, 2:15:58 AM1/7/14
to web...@googlegroups.com
Hi Shane,

I went through this with eric's assistance recently:- WebIOPi uses python 3.

How I managed to install requests for python3 as follows:

install pip for python3
sudo apt-get install python3-pip
sudo pip-3.2 install requests

Hope it works as I might need your help later

/Gerry


--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Best regards

Gerry Manley
SEEKING NEW OPPORTUNITIES!

Contact details:
Kyrkbyn 6
14565 Norsborg
gsm: +46 709980171

Linkedin profile: http://www.linkedin.com/pub/gerry-manley/4/835/46b

Eric PTAK

unread,
Jan 7, 2014, 4:07:23 AM1/7/14
to web...@googlegroups.com
try this one :
cd pyusb
sudo python3 setup.py install

WebIOPi detects which version of python are installed on the system and use the higher one.


On Tue, Jan 7, 2014 at 8:11 AM, Shane <sleste...@googlemail.com> wrote:

--

Shane Lester

unread,
Jan 7, 2014, 12:37:42 PM1/7/14
to web...@googlegroups.com, web...@googlegroups.com
Thanks Eric and Gerry, that cleared it up. I didn't realise I had to use python3. 
After the install I actually had a problem with the RobotArm module not loading. I changed the path to
#! /usr/bin/env python3
(previously just had env python) and this sorted it out too. 
Webiopi now activates the arm test program so thanks very much (off to complete the GUI now- should be a cinch). 

Thanks again. I'm very happy with both the forum help and webiopi. 

Going to donate now to support the project!

Shane

Eric PTAK

unread,
Jan 7, 2014, 1:20:00 PM1/7/14
to web...@googlegroups.com
I'm glad you finally got it !

Atul Vaghela

unread,
Jun 4, 2014, 8:59:47 PM6/4/14
to web...@googlegroups.com
I am having similar problems while loading the xbee module library Xbee-2.1.0 and serial module. How do i resolve this ? i am new to python and webiopi environment.

Thanks,

Atul
Reply all
Reply to author
Forward
0 new messages