InvalidAppConfigError: Duplicate module: my-service - google-app-engine

My computer (Windows 10) hosting my VM (Ubuntu 16.04) restarted last night (because Windows is a jerk) and now I can't seem to run my service locally. This was running fine yesterday and I haven't changed a single line of code. Only thing that happened was the reboot.
I am running dev_appserver.py ./ app.yaml.
My app.yaml file:
runtime: go
api_version: go1
service: my-service
handlers:
- url: /.*
script: _go_app
#[START env_variables]
env_variables:
GCLOUD_STORAGE_BUCKET: my-cloud-bucket
#[END env_variables]
and the error I get is:
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in <module>
_run_file(__file__, globals())
File "/usr/lib/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 350, in <module>
main()
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 338, in main
dev_server.start(options)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 94, in start
env_variables=parsed_env_variables)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 953, in __init__
module.module_name)
google.appengine.tools.devappserver2.errors.InvalidAppConfigError: Duplicate >module: my-service
Any advice?

You shouldn't need to specify both the application directory (./ in your case) and the app.yaml simultaneously. From Running the local development server:
Specify the directory path to your app, for example:
dev_appserver.py [PATH_TO_YOUR_APP]
Alternatively, you can specify the configuration file of a specific
service, for example:
dev_appserver.py app.yaml
Most likely the server detects the app.yaml from the directory specification and then gets it again from the app.yaml specification, leading to the duplicate service error.
I'd simply drop the ./ directory specification from the command line (I'd rather not rely on the auto-detection, which can fail miserably for multi-service apps).

Related

Using gcloud console for Google App Engine causes a Runtime error from metrics

I'm trying to use the gcloud console through the browser. When I clone my repository and start the dev server, I get a runtime error from metrics:
$ dev_appserver.py $PWD
Traceback (most recent call last):
File "/google/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 101, in <module>
_run_file(__file__, globals())
File "/google/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1041, in <module>
main()
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1037, in main
dev_server.stop()
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 845, in stop
metrics.GetMetricsLogger().Stop()
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/metrics.py", line 117, in Stop
total_run_time = int((Now() - self._start_time).total_seconds())
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'
I'm not calling the metrics module directly or otherwise using it. How can I disable it in the console or in the code so that I can start my app ok?
It runs ok locally via the SDK.
dev_appserver.py metrics were recently added in the Cloud SDK version 144.0.0 for users who have opted-in during SDK installation. The Cloud SDK installation provided in the Cloud console at https://console.cloud.google.com is also opted in to using these metrics.
In response to this post, we've added some additional logic to prevent this misleading error message in the future. This update will appear in one of the upcoming releases.
I got this working by resolving an issue in my app.yaml file, one of my routes wasn't specified correctly.
Fixing that route with a leading slash, and escaping the dot within the route regex, seemed to resolve the error too:
diff --git a/app.yaml b/app.yaml
index 8a165a0..39c68b3 100644
--- a/app.yaml
+++ b/app.yaml
## -13,7 +13,7 ## handlers:
- url: /ui
static_dir: ui
-- url: robots.txt
+- url: /robots\.txt$
static_files: robots.txt
upload: robots.txt

Deploying Google app engine with python failed

I try to deploy some files on google CDN (appspot) with Google App Engine release 1.19.7 and Python 2.7.9.
I'm sure that's it's not a big problem but I'm not a specialist.
I've created the application in 'Google developers'
The content of the file app.yaml is :
application: o-naturel version: 1 runtime: python27 api_version: 1 threadsafe: true
# Expiration des fichiers : 30 jours default_expiration: "30d"
handlers:
- url: /styles static_dir: styles
- url: /images static_dir: images
- url: /files static_dir: files
#- url: /.*
# static_files: index.html
# upload: index.html
Find below the errors during the deployment. Hope I will get an answer because I can not follow the development of my web site. Many thanks in advance !!!!
2014-12-12 17:56:28 Running command: "['C:\\Python27\\pythonw.exe', '-u', 'C:\\Program Files (x86)\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=patrick.sanchez24#gmail.com', '--passin', 'update', 'D:\\Cdn-App_o-naturel']"
05:56 PM Application: o-naturel; version: 1
05:56 PM Host: appengine.google.com
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 127, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 123, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 5397, in <module>
main(sys.argv)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 5388, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2978, in Run
self.action(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 5044, in __call__
return method()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3791, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3812, in _UpdateWithParsedAppYaml
updatecheck.CheckForUpdates()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\sdk_update_checker.py", line 243, in CheckForUpdates
runtime=runtime))
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 424, in Send
f = self.opener.open(req)
File "C:\Python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1240, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
2014-12-12 17:56:31 (Process exited with code 1)
You can close this window now.
If you use Python 2.7.9, you should install Python 2.7.8.
When I ran GAE/P in Python 2.7.9, this error occured just like you.
However, it worked correctly, when I ran GAE/P in Python 2.7.8.
Probably, the difference is between Python 2.7.9 released 2014-12-10 and GAE/P released 2014-12-8 now.
Please try Python 2.7.8.
There seems to be a bug in the SDK.
See Deep's link above.
for me simplest solution was to add:
--skip_sdk_update_check=yes to the additional options.
Later I will check for and download a newer version manually, and then remove the option again.
If you want to continue using Python 2.7.9, the solution as shown in:
https://code.google.com/p/googleappengine/issues/detail?id=11536 worked for me.
Had to change three lines of code and it started working.
This is fixed for me by upgrading Google App Engine SDK to 1.9.18 (in GoogleAppEngineLauncher UI use Help > Check for updates).
I'm running Python 2.7.9.

Fatal devappserver2 error: PYTHON_EGG_CACHE in Appengine 1.7.6 and 1.7.5 python 2.7, win7

I attempted to use Appengine SDK version 1.7.6 but was receiving fatal errors (same as outlined below) so reverted to 1.7.5, where my app works fine. However, the errors I saw in 1.7.6 recur when I attempt to run the experimental devappserver in 1.7.5. I am running Python 2.7 on a win 7 machine. Standard install selections for AppEngine.
These error messages refer to permissions relating to the PYTHON_EGG_CACHE, but...
- 1) They do not occur for the 'old' dev_appserver
- 2) The application can successfully extract files to the location noted. In fact, I changed the path of the PYTHON_EGG_CACHE to another location, gave it wide open permissions, and still received the error.
- 3) I have pyyaml in my site-packages, so am not sure why it would need to do a temporary extract anyway.
Any help looking for a resolution to this would be appreciated, since I'll be forced to use the new devappserver in a couple of releases time.
Command line error dump below:
python "C:\Program Files (x
86)\Google\google_appengine\devappserver2.py" .
WARNING 2013-03-25 19:10:41,029 devappserver2.py:497] devappserver2.py is curre
ntly experimental but will eventually replace dev_appserver.py in the App Engine
Python SDK. For more information and to report bugs, please see: http://code.go
ogle.com/p/appengine-devappserver2-experiment/
INFO 2013-03-25 19:10:41,171 appcfg.py:618] Checking for updates to the SDK.
WARNING 2013-03-25 19:10:44,525 simple_search_stub.py:975] Could not read searc
h indexes from c:\users\ben\appdata\local\temp\appengine.dev~upskillme-main.Ben\
search_indexes
INFO 2013-03-25 19:10:44,539 api_server.py:148] Starting API server at: http
://localhost:49302
INFO 2013-03-25 19:10:44,555 dispatcher.py:96] Starting server "default" run
ning at: http://localhost:8080
INFO 2013-03-25 19:10:44,571 admin_server.py:112] Starting admin server at:
http://localhost:8000
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line
150, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line
146, in run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\de
vappserver2\python\runtime.py", line 39, in <module>
from google.appengine.ext.remote_api import remote_api_stub
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remo
te_api\remote_api_stub.py", line 75, in <module>
import yaml
File "C:\Program Files (x86)\Google\google_appengine\lib\yaml-3.10\yaml\__init
__.py", line 14, in <module>
from cyaml import *
File "C:\Program Files (x86)\Google\google_appengine\lib\yaml-3.10\yaml\cyaml.
py", line 5, in <module>
from _yaml import CParser, CEmitter
File "C:\Python27\lib\site-packages\pyyaml-3.10-py2.7-win32.egg\_yaml.py", lin
e 7, in <module>
File "C:\Python27\lib\site-packages\pyyaml-3.10-py2.7-win32.egg\_yaml.py", lin
e 4, in __bootstrap__
File "C:\Python27\lib\site-packages\pkg_resources.py", line 882, in resource_f
ilename
self, resource_name
File "C:\Python27\lib\site-packages\pkg_resources.py", line 1351, in get_resou
rce_filename
self._extract_resource(manager, self._eager_to_zip(name))
File "C:\Python27\lib\site-packages\pkg_resources.py", line 1406, in _extract_
resource
manager.extraction_error() # report a user-friendly error
File "C:\Python27\lib\site-packages\pkg_resources.py", line 928, in extraction
_error
raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
cache:
[Error 5] Access is denied: 'C:\\Users\\Ben\\AppData\\Roaming\\Python-Eggs\\py
yaml-3.10-py2.7-win32.egg-tmp\\_yaml.pyd'
The Python egg cache directory is currently set to:
C:\Users\Ben\AppData\Roaming\Python-Eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 551, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\de
vappserver2\server.py", line 1045, in _loop_adjusting_instances
self._adjust_instances()
If anyone comes along with the same issue, the resolution that worked for me was as follows:
Unzip the PyYAML-3.10-py2.7-win32.egg in your python27 site-packages
directory into a new directory within site-packages. You'll need to
unzip it to into a directory name like NEWPyYAML-3.10-py2.7-win32.egg
to avoid name conflicts.
Rename your original egg. to something else (e.g., OLDPyYAML-3.10-py2.7-win32.egg).
Rename your new directory to PyYAML-3.10-py2.7-win32.egg
All references to the egg will now actually point to a directory in your site-packages containing the unzipped python files. The new devappserver should be able to work with this.
Unsure how to unzip an egg in windows? See here (presuming you have Winzip or similar installed):
http://mail.python.org/pipermail/chicago/2007-July/002301.html

cannot run helloworld in Google app engine launcher

Google App Engine Launcher suddenly not working when running any app, it works well yesterday.
Error produced:
wi2013-01-15 14:56:52 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--admin_console_server=', '--port=8080', 'C:\\Users\\Lawrence\\Documents\\guestbook-2']"
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 171, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 167, in run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 166, in <module>
from google.appengine.tools import appcfg
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 41, in <module>
import mimetypes
File "C:\Python27\Lib\mimetypes.py", line 29, in <module>
import urllib
File "C:\Python27\Lib\urllib.py", line 26, in <module>
import socket
File "C:\Python27\Lib\socket.py", line 47, in <module>
import _socket
ImportError: Module use of python25.dll conflict with this version of Python.
2013-01-15 14:56:52 (Process exited with code 1)
When you google this error, a lot of solution telling you to change the
System/ User Environment Variable to add C:\Python27;C:\Python27\Scripts; C:\Python27\Lib; C:\Python27\libs; etc, remove or add User Variable etc. All those trick not work for me.
I didn't install python25. Those programme refer to it and using import _socket are google app engine launcher itself or Google Drive, I have stopped my Google Drive already as people found this may cause problem. so I guess this GAE conflicted itself when some error happen inside it. The clue is I got another error in google app launcher log,C:\Program Files (x86)\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log
I'm using win 7 64 bits, GAE 1.7.4, Python 2.7.3
You need to edit app.yaml
you should have:
runtime: python
replace with:
runtime: python27
threadsafe: true
Pay attention to threadsafe:
https://developers.google.com/appengine/docs/python/python25/migrate27#threadsafe
Other setting of app.yaml
https://developers.google.com/appengine/docs/python/config/appconfig#Required_Elements
If you start from Python 2.5 please read:
https:// developers.google.com/appengine/docs/python/python25/migrate27#appyaml

GoogleAppEngine error: rdbms_mysqldb.py:74

Trying to do HelloWorld on GoogleAppEngine, but getting the following error.
C:\LearningGoogleAppEngine\HelloWorld>dev_appserver.py helloworld
WARNING 2012-07-17 10:21:37,250 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 133, in
run_file(file, globals())
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 129, in run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 694, in sys.exit(main(sys.argv))
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 582, in main root_path, {}, default_partition=default_partition)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3217, in LoadAppConfig raise AppConfigNotFoundError
google.appengine.tools.dev_appserver.AppConfigNotFoundError
I've found posts on GoogleCode, StackO regarding this issue. But no matter what I try, I still can't overcome this error.
Python version installed on Windows 7 machine is: 2.7.3
GAE Launcher splash screen displays the following:
Release 1.7.0
Api versions: ['1']
Python: 2.5.2
wxPython : 2.8.8.1(msw-unicode)
Can someone help?
it's been a while, but I believe I've previously fixed this by adding import rdbms to dev_appserver.py
hmm.. or was that import MySQLdb? (more likely)
Runtime needed to be set to "Python27" not just "Python" and threadsafe needed be set to false, here is my app.yaml
application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /.*
script: helloworld.py
Here is my helloworld.py
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'
just had the exact same error messages: I found that restarting Windows fixed everything and I did not have to deviate from the YAML or py file given on the google helloworld python tutorial.

Resources