I am trying to move a django project to google appengine. So I followed http://code.google.com/appengine/articles/django.html . But
django.dispatch.dispatcher.connect(
log_exception, django.core.signals.got_request_exception)
django.dispatch.dispatcher.disconnect(
django.db._rollback_on_exception,
django.core.signals.got_request_exception)
was giving me error saying can't find dispatcher.connect/dispatcher.disconnect . So I changed the code as
django.dispatch.dispatcher.Signal.connect(
log_exception, django.core.signals.got_request_exception)
But now , when I am running the application , I am getting following error
*File "C:\Program
Files\Google\google_appengine\google\appengine\tools\dev_appserver.py",
line 2208, in ExecuteOrImportScript
exec module_code in script_module.dict File
"C:\Personal\Study\Python\twtApp\src\main.py",
line 23, in
import django.dispatch.dispatcher.Signal
ImportError: No module named Signal*
As it's said the google article , I have copied django folders to top level folder of my projects .
Is there anything I am missing ?
Pls help ..
Your issue lies in Python being unable to import the Signal module. Make sure it's properly in your path, and that it isn't somehow missing from your Django install.
I would strongly recommend that you use the google-app-engine-django project instead. You'll have a lot more luck.
http://code.google.com/p/google-app-engine-django/
Related
I’m having problems with one module in my Visual Studio Core project. It is not being found. It generates this error:
File "C:\Users\danj\source\repos\project_django\comstockapt\comstockapt\urls.py", line 28, in
from comstockapt.email_accounts import views as email_views
ModuleNotFoundError: No module named 'comstockapt.email_accounts'
I’ve gone through many, many similar questions, but I can’t get it to work. I’m using the virtual environment. When I execute “python” in the terminal and then run ‘help(“modules email_accounts”)’ it shows the module with all of its files.
When I run help(“modules”), I see all of my modules listed in the response.
Here is my urls.py file within module comstockapt.comstockapt.
Here is my installed_apps:
I've checked environment variables, the virtual environment, the directory structure. What can I try next?
You should import views from email_accounts like this:
from email_accounts import views as email_views
(Modified to answer the questions in the first comment.)
I am using Flask in PyCharm and getting different results than when I run it from the terminal. In particular, the working directory of the Python program is different under Pycharm. So this code works correctly when running flask from the command line and the print os.getcwd() displays '/Users/Wes/Dropbox/Programming/Python/etpruncnt2'.
However if I run the same code in Pycharm the os.getcwd() displays '/Applications/PyCharm.app/Contents/bin' and the file open fails
with IOError: [Errno 2] No such file or directory: 'data/results.json'.
The root of the project in PyCharm is /Users/Wes/Dropbox/Programming/Python/etpruncnt2. I have also added a screenshot of the project structure in the PyCharm GUI.
I suppose I must have the configuration wrong in PyCharm. I have included a screenshot.
What should I do?
#app.route('/running_count')
def running_count():
print os.getcwd()
with open('data/results.json', 'r') as resultFile:
resultData = json.load(resultFile)
return str(resultData)
You Only Have Shown Script Path
How is project structure ? When you are creating new project you are telling pycharm the project root and may you mixed that part :)
I am going to close this. The immediate problem is that the Working Directory in the config was not filled in.
Most default setups for PyCharm do fill that in, but the setup for flask does not.
I have filed a low-urgency bug report with IntelliJ.
I'm far from Python expert, so please bear with me.
I'm using Slack python bot library, which utilizes module loading to execute users code.
I noticed a weird thing - when I launch my script, it says ImportError: Import by filename is not supported on a line self.module = __import__(name) (where name is relative path to the Python file). I don't quite understand the problem, because the owners of the library test their code with both 2.x and 3.x Python, and it DOES work on TravisCI.
I'm using Python 2.7.8 on Windows 7.
How do I fix the problem? I suspect something on my system is wrong. I read similar questions on SO and worked around the issue by using imp.load_source, but I would like to get to the bottom of it.
P.S. It also works if I upload it to Heroku, which by default runs 2.7.12
Am new to Flask development and am using an IDE like Pycharm for the first time, so please pardon the ignorance.
So while playing around with a project that I am working on to understand Flask, I created a virtual environment by the name venv. So the tree of my project would look something like :
my_project_directory
Project_specific_directories_and_files
requirements.txt
venv
To activate the virtual env, I used to do venv/bin/activate and my project would run as needed.
I came across virtualevnwrapper later and decided to use that. After installing it and setting it up, I moved over to the virtualenvwrapper way of working with virtual envs and completely removed(deleted) the venv directory from my project structure. The new project structure after deleting venv is as :
my_project_directory
Project_specific_directories_and_files
requirements.txt
Everything works fine. The project runs as expected.
However, now after the venv directory was removed, when I open my project in Pycharm, for my import statements like :
from flask import Flask, render_template, redirect, url_for, request, session, flash # , g
from flask_sqlalchemy import SQLAlchem
all the packages that I try importing gets underlined as error in the Pycharm IDE. I opened the Python console, in Pycharm, trying to debug the error and it gives the following error :
Error:Cannot run program "/Users/my_user_name/Desktop/some_parent_directory/my_project_directory/venv/bin/python" (in directory "/Users/my_user_name/Desktop/some_parent_directory/my_project_directory"): error=2, No such file or directory
Now I thought that apparently Pycharm is still using it's cache. So I tried invalidating the cache and restarting Pycharm as explained here, but the problem was still there.
Now I have 2 questions:
Why is Pycharm behaving this way? I removed the venv directory completely etc. Why is it still referencing the old (venv) location?
If it really is not able to resolve the dependencies, how exactly then is my project running all fine? Shouldn't it break the app?
Ok. After some further digging now, I was able to get the errors flagged in Pycharm rectified. I went to Pycharm -> Preferences -> Project: my_project_directory -> Project Interpreter & found that it was 'for some reason' still pointing to the older venv directory. From the drop down of the 'Project Interpreter:' section, I chose the path to my virtualenv created by virtualenvwrapper & saved the changes by Apply->Ok. This removed the error indications from the code in Pycharm. Although solved, the mystery of what/why was this happening is still unsolved for me. – qre0ct Jul 12 at 17:13
Moreover, I also removed the unused/deleted interpreters from the list of project interpreters by going to the 'more' section in the 'Project Interpreter' part and using the '-' at the bottom to remove the ones not needed.
I have succesfully installed Postgres.App. It works just fine if I have this in settings.py:
GEOS_LIBRARY_PATH="/Applications/Postgres.app/Contents/Versions/latest/lib/libgeos_c.dylib"
If I remove the above line and execute manage.py loaddata mydata, I get:
ImportError: Could not find the GEOS library (tried "geos_c", "GEOS"). Try setting GEOS_LIBRARY_PATH in your settings.
The question: is it possible to make things work without GEOS_LIBRARY_PATH set in settings.py? The reason is that in our team not all are using OSX + Postgres.App and the path is not the same for all developers. Django Docs mention usage of LD_LIBRARY_PATH, but having the next line exported in bash did nothing:
LD_LIBRARY_PATH="/Applications/Postgres.app/Contents/Versions/latest/lib/"
I still get the same error. Am I having a wrong syntax or is there another solution so that everyone can have individual path to the library?