I'm building a project that uses django-app-engine, but get some import errors when running the project with the GAE launcher.
My first error is importing simplejson, same as: Error importing simplejson after upgrading to appengine dev server 1.7.6
I've resolved that issue by modifying old_dev_appserver.py in the GAE bundle to import 'json' instead of 'simplejson' (I hope it's ok that I modified the GAE bundle..)
After the change, I receive a new error:
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/cron/groc.py", line 31, in <module>
import antlr3
ImportError: No module named antlr3
In the link above, #trope actually commented on having the same issue, but I thought a new question would be better than adding comments to the original issue (which is resolved by changing simplejson to json)
As suggested here: Django App Engine can't find antlr3 module, I've tried to add
os.path.join(SDK_PATH, 'lib', 'antlr3')
And also tried to install the antlr3 runtime.
I feel this issue is different to the one above because it's a direct result of the simplejson workaround, but perhaps it is the same.
Python 2.7.2, GAELauncher 1.9.4
Any suggestions?
edit: I've also now tried the exact same setup/codebase on my PC with the latest version of Launcher, and I get the exact same two errors: first simplejson, then antlr3. Maybe that means it's an issue with the codebase/djangoappengine install?
OK, this should be solved. Make sure you have updated all the django nonrel projects (dbindexer, django, djangoappengine, djangotoolbox, and whatever else you use). Also, run gcloud components update from the command line.
In addition to adding os.path.join(SDK_PATH, 'lib', 'antlr3'), did you also actually download and install it? From the command line, run whereis antlr3.
Related
django works well on my local machine. But, when I deploy it to heroku, I see "ModuleNotFoundError" "No module named '_tkinter'". Though, I never imported "_tkinter" or "tkinter" in my code. Your help will be appreciated. Thank you.
ModuleNotFoundError at /
No module named '_tkinter'
Request Method: GET
Request URL: https://howididit.herokuapp.com/
Django Version: 4.0.6
Exception Type: ModuleNotFoundError
Exception Value:
No module named '_tkinter'
Exception Location: /app/.heroku/python/lib/python3.10/tkinter/init.py, line 37, in
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.10.5
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python310.zip',
'/app/.heroku/python/lib/python3.10',
'/app/.heroku/python/lib/python3.10/lib-dynload',
'/app/.heroku/python/lib/python3.10/site-packages']
If you don't use Tkinter, just remove it from /forms.py. otherwise it'll be imported.
If you want to use tkinter,then consider the below process
please try adding tkinter to your requirements.txt. If it fails, even after that, check if you have added Python buildpack. If both the cases pass, try shelling into your Heroku instances and run the following command:
sudo apt install python3-tk
This will install Tkinter library in your instance of Heroku. That will resolve your error.
I found out these from pyexpat import model from turtle import title from attr import fields where imported in my forms.py. After deleting them, The problem was solved. Again, thank you all guys for your time, I really appreciate it.
Okay so for anyone looking at this in the future and banging their head against the desk...this is what worked for me:
I started with a new Hello World app and started adding bits of my original code until i got to the error
found out that one of the modules I was using : icu, was using tkinter and i needed to install the Pyicu module instead
pip installed directly into heroku bash console instead of through my app
None of the answers i found online had worked for me, and I think its because this error isnt from having tkinter directly in your app, but from another module thats calling it.
When in doubt do what I did and start a new project from scratch and add chunks of code until you get the error to see which module is creating it
Dont forget to change DEBUG to False in your settings file
I am spiking Flask based login and signup webapp.
I downloaded flask-login-example.
When I run the two example files(flask-login-example.py, flasklogin.py), I got error messages.
For importing flask.ext.login:
https://github.com/shekhargulati/flask-login-example/blob/master/flasklogin.py
For importing flask.login:
ModuleNotFoundError: No module named 'flask.login'
I installed flask-login package using the pip3 command, I got the same error messages for each example. What's wrong with my code? Which Python package should I install?
The link you've provided as example is a outdated reference source.
Looking on issues (this) in the same repository it's possible notice that package imports do not reflect the current package version anymore.
In new version of flask, use
from flask_login import LoginManager
and you'll found lots of package and imported this way in new version.
I am trying to push a flask app (Python 3.5) to Cloud Foundry (CF). The application takes a POST request (text file) and returns a message. It works locally (tested via Postman). However, when attempting to push it to CF, it gives the error -
ImportError: No module named queue
Here is my code which contains queue.
import queue as Queue
self._batch_queue = Queue.Queue(self.BATCH_QUEUE_MAX)
self._example_queue = Queue.Queue(self.BATCH_QUEUE_MAX * self._hps.batch_size)
I've tried the solutions suggested here, but neither of these solve my problem. I think the issue is with the Python in CF not having queue package. (I could be wrong).
Anyone ideas on how to go about solving this will be very appreciated. Thanks in advance!
As mentioned in the comments by #KlausD, it seems like you have the wrong version of Python installed. On Cloud Foundry, you would set the version by including a file called runtime.txt in the root of your project (i.e. the directory from which you're running cf push).
https://docs.cloudfoundry.org/buildpacks/python/index.html#runtime
That file is used to tell the Python buildpack which version of Python to install for you. Suggestions would be python-3.5.x or python-3.6.x which would install the latest 3.5 or 3.6 release. You can specify an exact version like python-3.5.5 but it's not recommended as it's easy to forget to update that file when new versions of Python come out.
You can see which versions of Python are supported by the buildpack here.
https://buildpacks.cloudfoundry.org/#/buildpacks/python/v1.6.17
(Note that link goes to the latest version of the buildpack at the time I wrote this, it will get out of date. In the future, just click the most recent version of the buildpack to see what ships with it).
I have a Flask project which I've put the flask module (version 0.9) directly beside my app.py file. I've done this so that I can bundle everything into a version control repository that won't require anyone else using it to install additional Python modules.
I want to use flask-login so I've tried to manually install it by downloading the latest version and putting the flask_login.py file in my "local" flask/ext/ directory. However, while I can import flask and import flask.ext, I am unable to import flask.ext.login with Python throwing ImportError: No module named flask.ext.login. import flask.ext.flask_login throws an import error as well.
Is there something I have to do differently if Flask and it's extensions are local to the app.py?
The solution is to put the flask_login.py file in the same directory as my app.py file. No modification of the flask/ext/__init__.py file is necessary.
The flask.ext module is intended only as a an extension importer, not a repository for installed extensions. Based on the import path, I thought the flask/ext folder was where extensions were to be copied. This was incorrect. Extensions simply need to be somewhere on the python path.
Python doesn't throw the exception in your case, this Flask module is responsible for modifying the standard import hook in the ext folder:
https://github.com/mitsuhiko/flask/blob/master/flask/exthook.py
So, I don't think putting flask_login.py into flask/ext is the right way to use extensions in Flask. The documentation recommends to use pip install flask-login or python setup.py install. After that you can do:
import flask_login
If you still want to do it manually, remove the setup() call from ext/__ init__.py.
It probably has a good reason why the Flask guys did it this way though :-)
Right, but the point was to manually install everything so it could be self-contained in a version control repository that won't require additional installs. I've looked at the setup.py file but can't determine how it achieves the installation. – Soviut Oct 25 at 10:06
Why not use virtualenv to achieve this? You can push your env to source control as well, although that's not normal usage.
See: http://www.virtualenv.org/en/latest/
I'm trying to get Google AppEngine to work on my Debian box and am getting the following error when I try to access my page:
<type 'exceptions.ImportError'>: No module named core.exceptions
The same app works fine for me when I run it on my other Ubuntu box, so I know it's not a problem with the app itself. However, I need to get it working on this Debian box. It originally had python 2.4 but after AppEngine complained about it I installed the python2.5 and python2.5-dev packages (to no avail).
I saw on this Google Group post that it may be due to the version of AppEngine and just to reinstall it, but that didn't work. Any ideas?
Edit 1: Also tried uninstalling python2.4 and 2.5 then reinstalling 2.5, which also didn't work.
Edit 2: Turns out when I made AppEngine into a CVS project it didn't add the core directory into my project, so when I checked it out there literally was no module named core.exceptions. Re-downloading that folder resolved the problem.
core.exceptions is part of django; what version of django do you have installed? The AppEngine comes with the appropriate version for whatever release you've downloaded (in the lib/django directory). It can be installed by going to that directory and running python setup.py install