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.
Related
I am calling .py file from node.js using npm i cmd-node on windows it is working well and executing my .py file from .js file, but when I am deploying it on the server giving following error:
Note: I am not importing parse anywhere, it may be part if any dependency.
python script cmd error: Error: Command failed: python covert_to_csv.py
Traceback (most recent call last):
File "covert_to_csv.py", line 1, in <module>
import tabula
File "/home/ubuntu/.local/lib/python2.7/site-packages/tabula/__init__.py", line 3, in <module>
from .wrapper import (
File "/home/ubuntu/.local/lib/python2.7/site-packages/tabula/wrapper.py", line 20, in <module>
from .file_util import localize_file
File "/home/ubuntu/.local/lib/python2.7/site-packages/tabula/file_util.py", line 3, in <module>
from urllib.parse import urlparse as parse_url
ImportError: No module named parse
You are probably using different versions of python on your local machine compared to the server. Make sure it is the same version as your local machine and it'll work.
I am trying to use google endpoint v2
following this tutorial
I have done all steps up until the To generate the required configuration file: Step
But when i try the following command
python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname echo-api.endpoints.xxxxxxx.appspot.com
I get the following warning and error
WARNING: Could not find the fix_sys_path() function in dev_appserver.
If you encounter errors, please make sure that your Google App Engine
SDK is up-to-date. Traceback (most recent call last):
File "lib/endpoints/endpointscfg.py", line 59, in
import _endpointscfg_setup # pylint: disable=unused-import
File "D:\Libraries\Documents\transporter\lib\endpoints_endpointscfg_setup.py",
line 107, in
`
_SetupPaths()
File "D:\Libraries\Documents\transporter\lib\endpoints_endpointscfg_setup.py",
line 103, in _SetupPaths
from google.appengine.ext import vendor ImportError: No module named google.appengine.ext
And no OpenAPI configuration file is generated
I have reinstalled everything,updated everything , checked system variables but still getting the error
p.s on windows 7
#HondaGuy's Comment was the answer I added app-engine to my python path,
my python environment variable now looks like this
C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Program
Files (x86)\Google\Cloud
SDK\google-cloud-sdk\platform\bundledpython;C:\Program Files
(x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine;
I am trying to run a basic Flask app using Python 3.6. However, I get an ImportError: cannot import name 'ForkingMixIn'. I don't get this error when running with Python 2.7 or 3.5. How can I run Flask with Python 3.6?
from flask import Flask
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello, World!"
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\werkzeug\serving.py", line 65, in <module>
from SocketServer import ThreadingMixIn, ForkingMixIn
ImportError: No module named 'SocketServer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\fsk.py", line 9, in <module>
app.run()
File "C:\Python36\lib\site-packages\flask\app.py", line 828, in run
from werkzeug.serving import run_simple
File "C:\Python36\lib\site-packages\werkzeug\serving.py", line 68, in <module>
from socketserver import ThreadingMixIn, ForkingMixIn
ImportError: cannot import name 'ForkingMixIn'
This is fixed as of Werkzeug 0.11.15. Make sure you have installed the latest version of Werkzeug. pip install -U werkzeug.
This is a known issue that was reported to Werkzeug in anticipation of Python 3.6. Until that or another patch is merged and released, Werkzeug's dev server will not run on Python 3.6.
Check if OS can fork before importing ForkingMixIn since Python 3.6 will no longer define that when it is not available on the operating system (python/cpython#aadff9b) and ImportError: cannot import name 'ForkingMixIn' will occur.
In the mean time, you can run your app with an external WSGI server such as Gunicorn.
pip install gunicorn
gunicorn my_app:app
You can wrap your app in the debug middleware if you need the in-page debugger (as long as you only run Gunicorn with one worker).
I've tried looking for a fix, but wasn't able to. Sorry if this question exists elsewhere.
I'm following http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html, and am currently trying to make sure django works with uWSGI. I'm trying to run uWSGI --http-socket :8000 --module mysite.wsgi, but am getting:
Traceback (most recent call last):
File "./mysite/wsgi.py", line 13, in <module>
from django.core.wsgi import get_wsgi_application
File "/anaconda/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module>
from django.core.handlers.wsgi import WSGIHandler
File "/anaconda/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 3, in <module>
import cgi
File "/anaconda/lib/python2.7/cgi.py", line 50, in <module>
import mimetools
File "/anaconda/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/anaconda/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /anaconda/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
I already had issues with uWSGI not using the right installation.uwsgi would try to use /usr/local/bin/uwsgi despite
which uwsgi
//anaconda/bin/uwsgi
, resulting in No such file or directory. Currently, I set uWSGI="//anaconda/bin/uwsgi" to get around the problem at and get uwsgi to work, but I suspect a similar problem may be occurring. I think it might be trying to use /usr/bin/python instead of /anaconda/bin/python, and it can't import from anaconda, resulting in the error. However, I'm not sure how to fix it/confirm that this is the problem, and any advice would be appreciated.
Thanks!
EDIT: I have also tried import _io using all of the current versions of python installed, and there was no problem. brew unlink python helped deal with the conflicting anaconda version for the uwsgi problem (initially fixed with alias, as above), but this issue still exists.
EDIT: Removing anaconda from $PATH, and then reinstalling/unlinking/linking django, openssl, and libxml2 "works". I'll find out if this causes problems in the later steps shortly, but I still have no idea what was happening with the anaconda install. I'd really like to figure out what's going on since I use scipy/numpy/etc. very frequently, so this is definitely a temporary fix. Any ideas?
I just encountered this issue trying to run uwsgi on my mac with my django project
uwsgi --http :9090 --module uwsgi_django_project.wsgi
(in this case my django project was named uwsgi_django_project)
The stack-trace from uwsgi was
Traceback (most recent call last):
File "./uwsgi_django_project/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
File "/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/site-packages/django/utils/version.py", line 1, in <module>
import datetime
File "/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/datetime.py", line 8, in <module>
import math as _math
ImportError: dlopen(/opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/lib-dynload/math.cpython-38-darwin.so, 2): Symbol not found: _PyExc_MemoryError
Referenced from: /opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/lib-dynload/math.cpython-38-darwin.so
Expected in: flat namespace
in /opt/anaconda3/envs/django_uwsgi_39/lib/python3.8/lib-dynload/math.cpython-38-darwin.so
unable to load app 0 (mountpoint='') (callable not found or import error)
Very similar to the error OP was getting except Symbol not found: _PyExc_MemoryError instead.
I had installed uwsgi via pip inside my conda environment and apparently there is an incompatability between the package installed via pip and the anaconda environment's python.
The solution was to remove uwsgi from my environment
pip uninstall uwsgi
and install it using anaconda
conda install -c conda-forge uwsgi
after doing this and running uwsgi with my django app it worked fine.
Credit to this blog where I found the solution to my issue which probably would solve a lot of similar issues with uwsgi and django
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