GoPiGo library for python3?[SOLVED]


#1

just wondering if i can just copy and paste the library in python2 and use in python3 as i want to code in python3. Will i face any problems?


#2

I think we updated BrickPi_Python to work with Python3 a few months ago. It should work fine. The examples may need some adjustments.


#3

I’m curious. What do you have in mind when you say “copy/paste the library”?

When I want to code in Python3, I do the following:

cd ~/Desktop/GoPiGo/Software/Python
sudo python3 setup.py install

That installs the library for Python3

Or you can bring the library into the same folder as your code. That should work too.
Cleo


#4

from what i read, when i install the gopigo library, it is installed in the python2 library. So i assume that i cannot control the robot using python3 because import will fail. So what is the simplest way to use python3 to control the robot?


#5

As Cleo mentioned above, the easiest way to install the GoPiGo library systemwide is to fo the the GoPiGo python folder and install it using :

cd ~/Desktop/GoPiGo/Software/Python
sudo python3 setup install

This would let all your python3 programs access the GoPiGo library.

Karan


#6

I managed to get into the the required directory but when I tried:
sudo python3 setup install then i get this:
python3: can’t open file ‘setup’: [Errno 2] No such file or directory

What should i do?


#7

Sorry, my fault.

you have to put the extension at the end of the file
So once in the required directory, you need to type in:
sudo python3 setup.py install

ETA: I’ve edited the above post for future readers.


#8

thanks. it works now :slight_smile:


#9

I now have a problem running the library when i tried to load the library into the SD card that came with my RPi, (not from Dex Ind). I followed the instructions here:
http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the-raspberry-pi-gopigo/installing-gopigo-python-library/

then i get this error message about smbus not found. Managed to solve this reinstalling smbus. Then this error came up which i have no idea how to overcome.

File “build/bdist.linux-armv6l/egg/gopigo.py”, line 49, in <module> IOError: [Errno 2] No such file or directory

I further tried with python3 and this came up.
File “<frozen importlib._bootstrap>”, line 2237, in _find_and_load
File “<frozen importlib._bootstrap>”, line 2226, in _find_and_load_unlocked
File “<frozen importlib._bootstrap>”, line 1191, in _load_unlocked
File “<frozen importlib._bootstrap>”, line 1161, in _load_backward_compatible
File “usr/local/lib/python3.4/dist-packages/GoPiGo-0.0.0-py3.4.egg/gopigo.py”, line 49, in <module>
FileNotFoundError: [Errno 2] No such file or directory


#10

update: Not sure why but i follow the instructions on this page and changed the last step to sudo ./install.sh and now it works :slight_smile:
http://www.dexterindustries.com/GoPiGo/getting-started-with-your-gopigo-raspberry-pi-robot-kit-2/sdcard-2/


#11

Great to hear that you’re all set!