buildozer show me ModuleNotFoundError - kivy

I am trying to use chatterbot and kivy.
I tried to google search but without success.
I created this main.py file
from chatterbot import ChatBot
chatbot = ChatBot('Ron Obvious')
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
resp = str(chatbot.get_response("ciao come stai?"))
return Button(text=resp)
TestApp().run()
and it works on my computer. I generate the apk for my android smartphone with:
buildozer android debug deploy run
As soon as I open it it closes. so using the command:
adb logcat | grep python
I found that:
05-19 18:12:18.526 17276 17309 I python : Traceback (most recent call last):
05-19 18:12:18.526 17276 17309 I python : File "/media/mezzo/4345727E5C539F3E/Dropbox/Home/Scrivania/app/.buildozer/android/app/main.py", line 1, in <module>
05-19 18:12:18.527 17276 17309 I python : ModuleNotFoundError: No module named 'chatterbot'
05-19 18:12:18.527 17276 17309 I python : Python for android ended.
how can i fix it? thanks.

Mention the requirement in buildozer.spec in home directory.
requirements = python3,chatterbot

Related

vscode dev container python interactive (`tkagg`) plots

Expected Behavior (local environment: fresh MacOS 12.4 installation)
With no environment updates except $ pip3 install matplotlib, I can successfully run this simple plot from the Matplotlib documentation:
Example Code:
# testplot.py
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
fig.savefig("test.png")
plt.show()
Actual Output (saved to a .png after window opens):
Run $ python3 testplot.py in the terminal:
Observed Behavior (vscode python 3.8 dev container)
Disclaimer: This post does not address notebook-based plots (which work fine but are not always preferred)
However, when I run this in my dev container, I get the following error:
testplot.py:16: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
First Attempted Solution:
Following this previously posted solution, I specified the backend (export MPLBACKEND=TKAgg) before running the interpreter, but the error persists.
Second Attempted Solution:
Following the comments, I added the following lines to the script:
import matplotlib
matplotlib.use('tkagg')
In the v3.8 dev container, this addition changes the error to:
Traceback (most recent call last):
File "testplot.py", line 5, in <module>
matplotlib.use('tkagg')
File "/usr/local/python/lib/python3.8/site-packages/matplotlib/__init__.py", line 1144, in use
plt.switch_backend(name)
File "/usr/local/python/lib/python3.8/site-packages/matplotlib/pyplot.py", line 296, in switch_backend
raise ImportError(
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
Note: adding these two lines broke the local script as well. The point of the local example was to show that it plots stuff without installing anything except matplotlib.

Import cv2 working in terminal (after typing python3) but not in Pycharm

Import cv2 working in terminal (after typing python3) but not in Pycharm. In Pycharm, I get the following message:
ModuleNotFoundError: No module named 'cv2'
I have installed opencv and the Project Interpreter is Python3.6 in PyCharm.
System paths by using sys.path are:
From Terminal I get:
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/m3z47/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
From PyCharm, I get:
['/home/m3z47/PycharmProjects/Rephrase', '/home/m3z47/PycharmProjects/Rephrase', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/m3z47/PycharmProjects/Rephrase/venv/lib/python3.6/site-packages', '/home/m3z47/PycharmProjects/Rephrase/venv/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg', '/home/m3z47/PycharmProjects/Rephrase/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg']

Issues installing Drake on Ubuntu 18.04

Followed through installation tips, but after typing
$ python underactuated/src/double_pendulum/simulate.py
I get
ImportError: dynamic module does not define init function (init_module_py).
If I run python3 I get
ImportError: cannot import name 'FindResource'.
After typing $ python3 -c 'import pydrake; print(pydrake.__file__)' I get /opt/drake/lib/python3.6/site-packages/pydrake/__init__.py
Edit:
Full output of running python3
Traceback (most recent call last):
File "underactuated/src/double_pendulum/simulate.py", line 5, in <module>
from underactuated import FindResource, PlanarSceneGraphVisualizer
ImportError: cannot import name 'FindResource'
And full output of running python (without3):
Traceback (most recent call last):
File "underactuated/src/double_pendulum/simulate.py", line 1, in <module>
from pydrake.all import (AddMultibodyPlantSceneGraph,
File "/opt/drake/lib/python3.6/site-packages/pydrake/__init__.py", line 32, in <module>
from . import common
File "/opt/drake/lib/python3.6/site-packages/pydrake/common/__init__.py", line 3, in <module>
from ._module_py import *
ImportError: dynamic module does not define init function (init_module_py)
Version of python after typing python -V is Python 2.7.15+
The fact that the print test succeeds suggests that drake is installed correctly.
Please post the full output of running simulate.py with python3.

ModuleNotFoundError: No module named 'flask_restful'

I've been trying this for awhile now with no luck. Making a basic api but running into some trouble with the flask_restful module. This is my code:
import markdown
import os
import shelve
from flask import Flask, g
from flask_restful import Resource, Api, reqparse
app = Flask(__name)
#app.route("/")
def index():
with open(os.path.dirname(app.root_path) +
'/README.md', 'r') as markdown_file:
content = markdown_file.read()
return markdown.markdown(content)
This is my requirements.txt:
docker==3.4.1
docker-compose==1.22.0
docker-pycreds==0.3.0
dockerpty==0.4.1
docopt==0.6.2
Flask==1.0.2
Flask-RESTful==0.3.6
requests==2.18.4
urllib3==1.22
websocket-client==0.48.0
This is what I get as an error when running docker-compose up:
Starting python-rest_device-registry_1 ... done
Attaching to python-rest_device-registry_1
device-registry_1 | Traceback (most recent call last):
device-registry_1 | File "./run.py", line 1, in <module>
device-registry_1 | from device_registry import app
device-registry_1 | File "/usr/src/app/device_registry/__init__.py", line 6,
in <module>
device-registry_1 | from flask_restful import Resource, Api, reqparse
device-registry_1 | ModuleNotFoundError: No module named 'flask_restful'
python-rest_device-registry_1 exited with code 1
My docker file is this:
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./run.py" ]
What am I doing wrong here? I pip installed Flask and flask_restful but I'm lost for word on what's going on.
It does not look like you are using flask_restful in the code you are showing here. You are just importing it. It might be possible that you started out with just some flask code, which imports ok, then added flask-restful to your requirements file but docker in unaware of it and it has a cached version of that part of the container.
Try to decouple your problem, start by running your python sample outside docker, in a plain old virtualenv and make sure that starts. Then mess look into how docker is installing or not your newly added requirements.

I properly installed PIL but still get the No Module Error

Grizz-MacBook-Pro:~ Grizz$ cd /usr/local/lib/python2.7/site-packages
Grizz-MacBook-Pro:site-packages Grizz$ ls
PIL pip-6.0.8-py2.7.egg
Pillow-2.7.0-py2.7.egg-info setuptools-12.0.5-py2.7.egg
PyQt4 setuptools.pth
easy-install.pth sip.so
hgext sipconfig.py
homebrew-pillow-nose.pth sipdistutils.py
mercurial sitecustomize.py
mercurial-3.3-py2.7.egg-info sitecustomize.pyc
It looks like PIL is installed in the correct PATH and when I go to use it in Sublime I get the:
'Traceback (most recent call last):
File "/Users/Grizz/Documents/Python Files/Weather APP/WeatherApp.py", line 4, in <module>
from PIL import Image
ImportError: No module named PIL
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/Grizz/Documents/Python Files/Weather APP/WeatherApp.py"]
[dir: /Users/Grizz/Documents/Python Files/Weather APP]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
I'm hoping to figure out either how to change the PIL path to ammend it to my system python path so I can run it in my interpreter or to uninstal and redownload PIL the correct way.
I'm new to Mac OS and have been able to troubleshoot most everything until now. I'm guessing it's because I'm running off my sys Python 2.7 and not a brew installeld 2.7... can someone walk me through this?

Resources