Oled sample project
-
I am trying to learn using the sample stock ticker project on the wiki page. I have the oled expansion correctly installed, I can use the console and write to the oled. However when I try to run the stock_script.py I get an error on the import of urllib in line 4 and error on import of json on line 5
import: not foundI am attempting to understand where these would be imported from so I can make certain that I have the correct modules installed. I did expand the storage to the usb storage and installed the full python environment.
Any help would be appreciated
-
As an update, I am using the sample on the wiki page Oled Expansion. Here is the code:
#!/usr/bin/env python
import urllib
import json
myfile = open('/usr/bin/ticker.txt', 'r')
rg=myfile.read()
site="http://www.google.com/finance/info?q="+rg
jfile=urllib.urlopen(site)
jsfile=jfile.read()jsfile=jsfile.replace("\n","")
jsfile=jsfile.replace("/","")
jsfile=jsfile.replace("]","")
jsfile=jsfile.replace("[","")
a=json.loads(jsfile)
ticker=a['t']
price=a['l_fix']
info=ticker+":"+price
print infoSo the errors I get when attempting to run this are Import: not found
This is for both the lines calling for urllib and json to be imported into the environment. This fails I am guessing because I do not had urllib or json either installed, or in the correct location for the command to find them. Any help?
-
@Dan-Johnson
What was the command you used to install python?
If you did:opkg update opkg install python-light
You only have the smallest possible Python install which would explain the missing modules.
Try running the following to install the full version of Python:
opkg update opkg install python
-
I installed the full version of python. I wonder if it is looking for those modules in some other directory? they appear to be installed, but still get the errors.
-
@Dan-Johnson Odd... Can you try running
opkg list-installed | grep -i python
and posting the output?
-
package python (2.7.9-5) installed in root is up to date.
root@Omega-2044:/# opkg list-installed | grep -i python
python - 2.7.9-5
python-base - 2.7.9-5
python-codecs - 2.7.9-5
python-compiler - 2.7.9-5
python-ctypes - 2.7.9-5
python-db - 2.7.9-5
python-decimal - 2.7.9-5
python-distutils - 2.7.9-5
python-email - 2.7.9-5
python-gdbm - 2.7.9-5
python-light - 2.7.9-5
python-logging - 2.7.9-5
python-multiprocessing - 2.7.9-5
python-ncurses - 2.7.9-5
python-openssl - 2.7.9-5
python-pydoc - 2.7.9-5
python-setuptools - 7.0-1
python-sqlite3 - 2.7.9-5
python-unittest - 2.7.9-5
python-xml - 2.7.9-5
root@Omega-2044:/#
-
@Dan-Johnson can you check that you have the correct the urllib and json modules? They should be listed in the /usr/lib/python2.7 directory.
-
in the /usr/lib/python2.7 directory I have a json directory installed, then a urllib.py file
How do I check which version these are? I opened the urllib.py file and there is not version information included. Are they correct since they are installed in the python2.7 directory? I did not specifically install these.
-
I have considered flashing the whole thing and starting from scratch to get a clean install. Perhaps there is something there that is wonky and just needs to be reinstalled?
-
@Dan-Johnson yeah, maybe a factory reset will do the trick. Let us know how it goes!
-
ok so i removed both the oled display and the usb expansion. Then did a factory reset. reinstalled the usb expansion, and keyed in the scripts. shut down the onion, and reinstalled the oled display. rebooted and ran the scripts.
I got the correct display on the oled.I think I read somewhere that there is a bug in the oled control library that is slated for a future firmware update with the error 'write" I got the error, but the script works. Thanks for the help
-
@Dan-Johnson Glad to hear that it worked out!
Can you post the error message you get from the OLED library?Btw, the board is the Omega, the team behind it is Onion