Is CherryPy broken? I just set it up and tried to use the routes dispatcher but it has an import error, my code is as follows:
import cherrypy
mapper = cherrypy.dispatch.RoutesDispatcher()
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jwesonga/environments/cherrypy/lib/python2.6/site-packages/CherryPy-3.2.2-py2.6.egg/cherrypy/_cpdispatch.py", line 463, in __init__
import routes
ImportError: No module named routes
I'm on a Mac and I tried both 3.2.2 and 3.0 using virtualenv for the latter.
I have successfully used CherryPy with the routes dispatcher under OS X.
The error you've shown is:
ImportError: No module named routes
This is pretty clear -- Python can't find the routes modules. Have you installed it? This is not part of CherryPy, it's a separate module that you will need to install. If you're using MacPorts, you should be able to:
port install py-routes
(Or py25-routes or py26-routes depending on which Python you're using). If you're using virtualenv, you can simply run:
easy_install routes
Related
from waitress import serve # error line
import app # python file where flask code is written
serve(app.app,port=8000,thread=55)
Python version : 3.7
waitress version : try with 1.4.1 and 1.3.0*
Stack Trace
C:\Users\ashish.kamble\ModelDeployment\Scripts\python.exe C:/Users/ashish.kamble/PycharmProjects/ModelDeployment/waitress.py
Traceback (most recent call last):
File "C:/Users/ashish.kamble/PycharmProjects/ModelDeployment/waitress.py", line 1, in <module>
from waitress import serve
File "C:\Users\ashish.kamble\PycharmProjects\ModelDeployment\waitress.py", line 1, in <module>
from waitress import serve
ImportError: cannot import name 'serve' from 'waitress' (C:\Users\ashish.kamble\PycharmProjects\ModelDeployment\waitress.py)
Process finished with exit code 1
Your Error occurred because of your file name is waitress.py.
When you run your code your waitress keyword work as an object of your file. There for if you want to get rid of from that error rename your python file into which not represent your libraries.
Addition -: It is better to install libraries using Pycharm project interpreter. Follow these steps to install libraries using interpreter.
On Ubuntu 16.04, am suddenly getting import errors from the local GAE development server.
The local dev server starts up, including the admin interface, but app no longer loads.
Native python imports of the same library on same machine (in this case "from google.cloud import datastore") work fine.
The GAE standard app does run when deployed, but development just got a little challenging.
google-cloud is version 0.27.0
gcloud components is 172.0.1
python is Anaconda 2.7.13
GAE is standard
I have confirmed to the best of my middling abilities that $PATH is correct for all named libraries.
I have removed and re-added all the named libraries to no effect.
cachetools(2.0.1) it should probably be noted, is installed as a dependency of the google cloud libraries, so I don't think this is addressable through requirements.txt or "libraries" in app.yaml.
I did recently go through a cycle of removing and adding libraries to fix a problem with apache_beam 2.0.1, so I may have jacked up something else, but am not sure where to look.
Suggestions deeply appreciated. Full traceback (from admin, same as from app):
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/request_handler.py", line 232, in handle_interactive_request
exec(compiled_code, self._command_globals)
File "<string>", line 1, in <module>
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/cloud/datastore/__init__.py", line 61, in <module>
from google.cloud.datastore.client import Client
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/cloud/datastore/client.py", line 23, in <module>
from google.cloud.client import ClientWithProject
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/cloud/client.py", line 27, in <module>
from google.oauth2 import service_account
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/oauth2/service_account.py", line 79, in <module>
from google.auth import jwt
File "/home/brian/anaconda3/lib/python2.7/site-packages/google/auth/jwt.py", line 49, in <module>
import cachetools
ImportError: No module named cachetools
The stacktrace indicates you're running the libraries from the local system installation (the site-packages dir), not from your app.
For standard env GAE apps you need to install the dependencies inside your app and they will be uploaded to GAE together with your app code.
More specifically you need to use the -t <your_app_lib_dir> option for the pip installation. From Installing a third-party library:
Use pip (version 6 or later) with the -t <directory> flag to copy the libraries into the folder you created in the previous
step. For example:
pip install -t lib/ <library_name>
I addressed my problem through the requirements.txt file in app root directory.
I had: google-cloud==0.22.0
and changed it to: google-cloud==0.27.0
which fixed it.
I have Google App Engine Python SDK installed and working with the GUI. However, now I am locally trying to test my app using unittest in a virtualenv. Everything is fine until I try to access google.appengine.ext.testbed. How do I access the SDK in this context? My error is included below.
Traceback (most recent call last):
File "tests.py", line 4, in <module>
from google.appengine.ext import testbed
ImportError: No module named google.appengine.ext
update: In further research, I've found that GAE "doesn't play well" with virtualenv. Subsequently, I installed all of my dependencies globally. The issue remains unchanged, so I think we can rule out virtualenv as the culprit.
I'm using Ubuntu 11.04 (natty). I have been using Suds to consume a SOAP web service. Everything was working fine... until it wasn't. I can no longer import Suds. I've uninstalled and re-installed Suds from the Ubuntu repositories but still get the same import error (see IDLE traceback below). I'm using Python 2.7.1 and Suds 0.4.1-2. Does anyone have any ideas on how to solve this problem??
>>> import suds
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import suds
File "/usr/lib/pymodules/python2.7/suds/__init__.py", line 154, in <module>
import client
File "/usr/lib/pymodules/python2.7/suds/client.py", line 23, in <module>
import suds.metrics as metrics
File "/usr/lib/pymodules/python2.7/suds/metrics.py", line 23, in <module>
from logging import getLogger
ImportError: cannot import name getLogger
>>>
logging is a standard module of Python. There are several possible reasons why Python can't find it anymore:
The is another logging module in the path (print sys.path to get a list of paths Python will search)
Someone changed PYTHONPATH (the default Python search path)
Someone messed with the Python installation (deleted the logging module)
I'm trying to install Plone 3.3rc4 with plone.app.blob and repoze but nothing I've tried has worked so far. For one attempt I've pip-installed repoze.zope2, Plone, and plone.app.blob into a virtualenv. I have this version of DocumentTemplate in the virtualenv's site-packages directory and I'm trying to get it running in RHEL5.
For some reason when I try to run paster serve etc/zope2.ini in this environment way Python gives the message ImportError: No module named DT_Util? DT_Util.py exists in the directory, __init__.py is there too, and the C module it depends on is there. I suspect there's some circular dependency or failure when importing the C extension. Of course this module would work in a normal Zope install...
>>> import DocumentTemplate
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "DocumentTemplate/__init__.py", line 21, in ?
File ".../lib/python2.4/site-packages/DocumentTemplate/DocumentTemplate.py", line 112, in ?
from DT_String import String, File
File ".../lib/python2.4/site-packages/DocumentTemplate/DT_String.py", line 19, in ?
from DocumentTemplate.DT_Util import ParseError, InstanceDict
ImportError: No module named DT_Util
I must say I doubt DocumentTemplate from Zope will work standalone. You are welcome to try though. :-)
Note that DT_Util imports C extensions:
from DocumentTemplate.cDocumentTemplate import InstanceDict, TemplateDict
from DocumentTemplate.cDocumentTemplate import render_blocks, safe_callable
from DocumentTemplate.cDocumentTemplate import join_unicode
You'll need to make sure those are compiled. My guess is that importing the cDocumentTemplate module fails and thus the import of DT_Util fails.