django-nonrel / djangoappengine

Django backends for App Engine (datastore, mail, ...)
BSD 3-Clause "New" or "Revised" License
268 stars 79 forks source link

cannot import name dev_appserver #86

Open ronaldocpontes opened 10 years ago

ronaldocpontes commented 10 years ago

I am having this problem on a MAC Mountain Lion...

./manage.py runserver

Traceback (most recent call last):
  File "./manage.py", line 4, in <module>
    import settings # Assumed to be in the same directory.
  File "/Users/ronaldo.pontes/projects/java/py-vm/django-app/settings.py", line 4, in <module>
    from djangoappengine.settings_base import *
  File "/Users/ronaldo.pontes/projects/java/py-vm/django-app/djangoappengine/settings_base.py", line 6, in <module>
    setup_env()
  File "/Users/ronaldo.pontes/projects/java/py-vm/django-app/djangoappengine/boot.py", line 76, in setup_env
    setup_project()
  File "/Users/ronaldo.pontes/projects/java/py-vm/django-app/djangoappengine/boot.py", line 137, in setup_project
    from .utils import have_appserver, on_production_server
  File "/Users/ronaldo.pontes/projects/java/py-vm/django-app/djangoappengine/utils.py", line 20, in <module>
    "Error was: %s" % e)
Exception: Could not get appid. Is your app.yaml file missing? Error was: cannot import name dev_appserver
aburgel commented 10 years ago

Do you have the app engine SDK installed in the correct place?

ronaldocpontes commented 10 years ago

It is installed and I used it to create the symlinks. The project actually works when I use the SDK GUI to start/deploy the app but I can't start or use any of the manage.py commands via the cmd line

ronaldocpontes commented 10 years ago

App engine SDK is acessible from /usr/local/google_appengine...

ls -1 /usr/local/google_appengine
BUGS
LICENSE
README
RELEASE_NOTES
VERSION
_php_runtime.py
_python_runtime.py
api_server.py
appcfg.py
backends_conversion.py
bulkload_client.py
bulkloader.py
demos
dev_appserver.py
dev_appserver.pyc
download_appstats.py
endpointscfg.py
gen_protorpc.py
google
google_appengine
google_sql.py
lib
new_project_template
old_dev_appserver.py
php
php_cli.py
remote_api_shell.py
run_tests.py
tools
wrapper_util.py
wrapper_util.pyc
ronaldocpontes commented 10 years ago

on djangoappengine/utils.py there is an import for dev_appserver

else:
    try:
        from google.appengine.tools import dev_appserver

However, this module doesnt exist on my version of the SDK...

ls /usr/local/google_appengine/google/appengine/tools/dev_*
/usr/local/google_appengine/google/appengine/tools/dev_appserver_apiserver.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_blobimage.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_blobstore.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_channel.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_index.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_login.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_login.pyc
/usr/local/google_appengine/google/appengine/tools/dev_appserver_main.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_multiprocess.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_oauth.py
/usr/local/google_appengine/google/appengine/tools/dev_appserver_upload.py

how should I proceed?

aburgel commented 10 years ago

the import should look like this:

        try:
            from google.appengine.tools import dev_appserver
        except ImportError:
            from google.appengine.tools import old_dev_appserver as dev_appserver

So if dev_appserver doesn't exist (it went away in SDK 1.9 I think) then it should load old_dev_appserver which does exist, at least in my SDK.

Which SDK version are you using? And which version of djangoappengine?

dxe4 commented 10 years ago

@aburgel can reproduce with app engine 1.9.7 + latest master of djangoappengine. https://github.com/potatolondon/djappengine/blob/master/lib/environ.py#L32

12:01 $ cat /usr/local/google_appengine/VERSION 
release: "1.9.7"
timestamp: 1401836503
api_versions: ['1']
supported_api_versions:
  python:
    api_versions: ['1']
  python27:
    api_versions: ['1']
  go:
    api_versions: ['go1']
  java7:
    api_versions: ['1.0']

:+1: the solution works

npgauth commented 9 years ago

The new version of app engine (1.9.17) has done away with old_dev_appserver (see SdkReleaseNotes) and this results in the exception:

File "/Users/username/git/project/build/djangoappengine/utils.py", line 24, in <module>
...
Exception: Could not get appid. Is your app.yaml file missing? Error was: cannot import name old_dev_appserver

I am now unable to run the development server. Symlinks are created. Any idea how I should proceed? Can we downgrade the app engine version? Will this affect deployment?

aburgel commented 9 years ago

@npgauth take a look at the devappserver2 branch in #77. It fixes this issue. I will merge it in to master soon.

slumtrimpet commented 9 years ago

When we say 'soon' ... how much longer are we looking at here? I'm still dead in the water on the 1.9.17 appengine.

aburgel commented 9 years ago

@slumtrimpet there are still some issues with the branch, but you can use it if you want. it should work pretty well.

huayueh commented 9 years ago

I have the same issue on it and tried on branch devappserver2. Another issue raise.

INFO 2014-12-27 13:11:38,700 sdk_update_checker.py:229] Checking for updates to the SDK. TypeError: do_open() got an unexpected keyword argument 'context'

leofiore commented 9 years ago

@huayueh i've been experienced the same problem with 1.9.15. looks like the solution is https://code.google.com/p/googleappengine/issues/detail?id=11536

jacobg commented 9 years ago

I just noticed on devappserver2, it seems this last update that the local shell does not use the datastore_path option, because my database is empty when using local shell. I have to dig further, but wondering if anyone else also see this?

wapcaplet commented 9 years ago

+1 for https://github.com/django-nonrel/djangoappengine/pull/77 - I was getting this error from manage.py:

Exception: Could not get appid. Is your app.yaml file missing?
Error was: cannot import name old_dev_appserver

Using the devappserver2 branch fixed it for me, and manage.py works now.