I'm trying to run this Google Endpoints python tutorial.
Traceback (most recent call last):
File "main.py", line 19, in <module>
import endpoints
File "/home/mica/.local/lib/python2.7/site-packages/endpoints/__init__.py", line 27, in <module>
from .apiserving import *
File "/home/mica/.local/lib/python2.7/site-packages/endpoints/apiserving.py", line 81, in <module>
from protorpc.wsgi import service as wsgi_service
ImportError: No module named wsgi
The error clearly comes from a python library. How am I supposed to fix the issue?
That "tutorial" doesn't correspond to any tutorial from the Google Endpoints team. The official tutorial uses this instead.
I just came up against the same problem in the 'hello world' tutorial for ProtoRPC.
As indicated by your error traceback, an ImportError occurs when Endpoints tries to import the protorpc.wsgi module, which is missing.
It turns out that the protorpc.wsgi module has been missing for some time. There's a pull request from 2016 that should have fixed the omission, but for some reason it was never merged. I've left a comment there, which is probably just about all we can do.
Related
This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 4 years ago.
I am new to python programming and started trying to fool around with flask this morning. I installed flask using pip and it seemed to work as expected. However, when I went to the python shell and typed import flask I got the following error:
>>> import flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/flask/__init__.py", line 17,
in <module>
from werkzeug.exceptions import abort
File "/usr/lib/python2.7/dist-packages/werkzeug/__init__.py", line
151, in <module>
__import__('werkzeug.exceptions')
File "/usr/lib/python2.7/dist-packages/werkzeug/exceptions.py", line
71, in <module>
from werkzeug.wrappers import Response
File "/usr/lib/python2.7/dist-packages/werkzeug/wrappers.py", line
27, in <module>
from werkzeug.http import HTTP_STATUS_CODES, \
File "/usr/lib/python2.7/dist-packages/werkzeug/http.py", line 23,
in <module>
from email.utils import parsedate_tz
File "/usr/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "random.py", line 6, in <module>
print(random.randint(1, 101))
AttributeError: 'module' object has no attribute 'randint''
I uninstalled flask using pip and tried again. No change. I installed flask using apt, same problem I even tried it on python 2, same error message. the really weird part is that it is giving me errors from a python3 shell session I did earlier in the week - the import random for random.py part of the message at the very end. Why would it spit out messages that have nothing to do with the import flask message?
It made me think that maybe I should see if a reboot would help, but no luck there either.
How does one troubleshoot an issue like this? googling the error hasn't helped and I am running out of ideas.
Thanks in advance
From what it looks like the error message you are receiving means you have a file name random.py being invoked. This can happen if the file is in the same folder you are running the command python2 or python3.
According to the error message:
print(random.randint(1, 101))
AttributeError: 'module' object has> no attribute 'randint''
It's trying to load that file. Rename your file to something else and it should work.
If you locate random.py in linux you will see it here (depending on your versions):
/usr/lib/python2.7/random.py
and
/usr/lib/python3.6/random.py
So, your random.py is causing the python command to override the base python random.py file
My background is Java/C++ and I'm very new to python. I'm trying to import pyodbc to my project which works alright if I do it via command line.
import odbc
However, when I try to do the same in pydev/eclipse, i get the following error which I cannot find a solution to. I suspect this may have something to do with Eclipse setup
Traceback (most recent call last):
File "C:\Users\a\workspace\TestPyProject\src\helloworld.py", line 2, in <module>
import pyodbc
File "C:\Users\a\AppData\Local\Continuum\Anaconda3\Lib\site-packages\sqlalchemy\dialects\mssql\pyodbc.py", line 105, in <module>
from .base import MSExecutionContext, MSDialect, VARBINARY
ImportError: attempted relative import with no known parent package
I'm really stuck here and any hints will be appreciated!
An incorrect library was imported into the External Libraries list of the project. After fixing it, the import is working.
i am running python 3.2.6 on an a2hosting shared server. when i do
import cgi
i get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.2/cgi.py", line 38, in <module>
from email.parser import FeedParser
File "/usr/lib64/python3.2/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib64/python3.2/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib64/python3.2/email/message.py", line 19, in <module>
from email import header
File "/usr/lib64/python3.2/email/header.py", line 17, in <module>
import email.base64mime
EOFError: EOF read where not expected
how can i solve this? i do not have root access.
edit:
this is the answer i got from a2hosting support:
Hello, Unfortunately, we really cannot provide development assistance here. This is quite above and beyond our scope of support. While we'd like to be able to provide support for each and every program, language, script, etc, that comes out, it's just physically impossible to do so. You'll want to work with your development team, or the applications developers to ensure that this is something that's investigated thoroughly.
i circumvented the issue by installing a different version of python, following this: https://www.a2hosting.com/kb/developer-corner/python/using-a-newer-version-of-python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/zmq/__init__.py", line 51, in <module>
from zmq import core, devices
File "/usr/local/lib/python2.7/dist-packages/zmq/core/__init__.py", line 26, in <module>
from zmq.core import (constants, error, message, context,
ImportError: /usr/local/lib/python2.7/dist-packages/zmq/core/socket.so: undefined symbol:
zmq_sendmsg
I am getting above error. I have followed steps given on the official site of ZeroMQ.
Had a similar issue when building for Java, UnsatisifedLinkError, after the so libraries were copied to /usr/local/lib, seems like your issue might be the same...I fixed it by logging off then logging back in again, I read something about the libraries not being visible until the user logs back in, weird, but it worked for me.
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)