Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 Import error on urllib.request. #187

Closed
ghost opened this issue Mar 25, 2015 · 1 comment
Closed

Python 3 Import error on urllib.request. #187

ghost opened this issue Mar 25, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 25, 2015

I created the following app:

version = "1.0"
import urllib.request
from kivy.app import App
form kivy.uix.label import Label

class MyApp(App):
def build(self):
return Label(text='test')
MyApp().run()

It runs on my computer, starting it with "python3 main.py". I can build an android apk with buildozer, but on my phone it crashes on startup. Logcat says "Import error, no module named request". I'm using the following:
Python 3.4.0
Buildozer 0.26
Kivy v1.8.0
running on Ubuntu 14.04.2
Any idea how to fix this?

@ghost
Copy link
Author

ghost commented Mar 27, 2015

It seems that the Python3 code is not properly translated to Python2. A workaround for me was to try the python3 import, if it doesn't work use the python2 import:

try:
    from urllib.request import urlretrieve
except:
    from urllib import urlretrieve

@ghost ghost closed this as completed Mar 27, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants