Cannot get python module ezsheets to work - python

I followed the steps from the official documentation for ezsheets. Both apis were activated (sheets and drive) and I turned on a python shell and imported the ezsheets module. But, it did not open the new browser window like the documentation said it's supposed to. I then tried and successfully got google sheets working with googles' quickstart script. I have the credentials-sheets.json and token.pickle in the same folder as my python scripts. Sheets api seems to work just fine on it's own but when I try it with ezsheets module I get a following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/method/.local/share/virtualenvs/python_projects-sgt8dc05/lib/python3.6/site-packages/ezsheets/__init__.py", line 1559, in listSpreadsheets
if not IS_INITIALIZED: init()
File "/home/method/.local/share/virtualenvs/python_projects-sgt8dc05/lib/python3.6/site-packages/ezsheets/__init__.py", line 1520, in init
creds = flow.run_local_server()
File "/home/method/.local/share/virtualenvs/python_projects-sgt8dc05/lib/python3.6/site-packages/google_auth_oauthlib/flow.py", line 443, in run_local_server
host, port, wsgi_app, handler_class=_WSGIRequestHandler)
File "/usr/lib/python3.6/wsgiref/simple_server.py", line 153, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.6/socketserver.py", line 456, in __init__
self.server_bind()
File "/usr/lib/python3.6/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.6/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.6/socketserver.py", line 470, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

ezsheets is trying to open webserver on port 8000 to obtain access token. But it is already occupied by another app.
Chech what app listens on port 8000 and close it.
On Linux you can check it with
netstat -tulpn | grep 8000
On Windows:
netstat -ab

Related

Vagrant python [Errno -2] Name or service not known

I am currently having a problem with vagrant. I used it before for a number of tasks, but now when I do vagrant up and then vagrant ssh, everything seems to work ok. Then I navigate into the vagrant folder to run a python file and when I run it I get the following error:
vagrant#vagrant:/vagrant$ python project.py
Traceback (most recent call last):
File "project.py", line 75, in
app.run(host='0.0.0.0.', port=8080)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 841, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 720,
in run_simple
s.bind((hostname, port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno -2] Name or service not known
I tried multiple times to restart vagrant, I also tried vagrant destroy and restarted the process. I manually deleted and powered it off a couple of times, but I always experience the same error. I would appreciate any help. Thank you.
The problem isn't vagrant... This line in the stacktrace shows there could be a typo in your python script
app.run(host='0.0.0.0.', port=8080)
Should be
app.run(host='0.0.0.0', port=8080)

redis.exceptions.ConnectionError: Error -2 connecting to localhost:6379. Name or service not known

I have this error when I run my code in server, my env is debian, and Python2.7.3
Traceback (most recent call last):
File "fetcher.py", line 4, in <module>
import mirad.fetcher_tasks as tasks
File "/home/mirad/backend/mirad/fetcher_tasks.py", line 75, in <module>
redis_keys = r.keys('*')
File "/home/mirad/backend/venv/local/lib/python2.7/site-packages/redis/client.py", line 863, in keys
return self.execute_command('KEYS', pattern)
File "/home/mirad/backend/venv/local/lib/python2.7/site-packages/redis/client.py", line 534, in execute_command
connection.send_command(*args)
File "/home/mirad/backend/venv/local/lib/python2.7/site-packages/redis/connection.py", line 532, in send_command
self.send_packed_command(self.pack_command(*args))
File "/home/mirad/backend/venv/local/lib/python2.7/site-packages/redis/connection.py", line 508, in send_packed_command
self.connect()
File "/home/mirad/backend/venv/local/lib/python2.7/site-packages/redis/connection.py", line 412, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error -2 connecting to localhost:6379. Name or service not known.
when I run redis-cli it works correctly without any error:
$ redis-cli
127.0.0.1:6379>
It seems that you are trying connect redis with server that is unidentified by your current Debian environment.
From Traceback, I see you are trying to connect using host name as localhost ,
r_server=redis.Redis(host="localhost",port=6379)
But , your system is unable to understand "localhost" , make entry in hosts file i.e saying 127.0.0.1 is localhost. add below code in /etc/hosts
127.0.0.1 localhost
otherwise connect redis using below command ;
r_server=redis.Redis(host="127.0.0.1",port=6379)
I faced a similar problem and later on realized that I have not opened redis in the terminal by command: $ redis-server.
Maybe it is the case.

Google AppEngine Python OSError "too many files open" at launch

I'm using ubuntu 13.10 running in a VM on OSX, python2.7 and GAE 1.8.8.
Lauching dev_appserver.py results in the following error:
INFO 2013-12-10 03:53:30,046 api_server.py:527] Saving search indexes
Traceback (most recent call last):
File "/home/ubuntu/xxxxxx/google_appengine/dev_appserver.py", line 197, in <module>
File "/home/ubuntu/xxxxxx/google_appengine/dev_appserver.py", line 193, in _run_file
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 872, in <module>
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 868, in main
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 707, in stop
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 141, in quit
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 528, in cleanup_stubs
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/api/search/simple_search_stub.py", line 984, in Write
File "/usr/lib/python2.7/tempfile.py", line 304, in mkstemp
File "/usr/lib/python2.7/tempfile.py", line 239, in _mkstemp_inner
OSError: [Errno 24] Too many open files: '/tmp/appengine.xxxxxx-hr-dev.ubuntu/tmpMVVXrH'
Any ideas?
Check the shared memory parameter, kern.sysv.shmseg on your linux system and set it right by increasing it.
To view the shared memory parameters, use:
sysctl -A | grep shm
To update that parameters, edit file:
sudo nano /etc/sysctl.conf
Refer to this SO answer for more information.

error on connection to redis-server in chat messenger

I have developed a chat system by Python. libraries been used :easygui,pycrypto,netifaces,stepic,redis,rabbitmq,pika,PIL and setuptools.
all libraries seems installed well refer to : python> import library
by using redis-server on localhost, users can connect to redis and signup,login,chat,.. but when setting redis on different device and change localhost to redis server ip in codes, i receive following errors. (am using lubuntu last version in oracle virtual machine)
enter code here
Traceback (most recent call last):
File "kiducb.py", line 392, in <module>
g = Gui()
File "kiducb.py", line 19, in __init__
self.welcome()
File "kiducb.py", line 33, in welcome
rl = self.login()
File "kiducb.py", line 126, in login
resp = self.check_up(fvals[0], fvals[1], mac)
File "kiducb.py", line 76, in check_up
val = self.re.get(username)
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 423, in get
return self.execute_command('GET', name)
File "/usr/lib/python2.7/dist-packages/redis/client.py", line 283, in execute_command
connection.send_command(*args)
File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 260, in send_command
self.send_packed_command(self.pack_command(*args))
File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 243, in
send_packed_command
self.connect()
File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 191, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting 10.1.1.12:6379. Connection refused.
to solve this problem, i removed the redis-server which earlier i installed by useing apt-get from system, and i folowed this link instruction: https://www.digitalocean.com/community/articles/how-to-install-and-use-redis

Configuring the Google App Engine SDK for offline use

How can I configure the Google App Engine SDK to run the local development server without requiring a network connection? I've tried removing ~/.appcfg_nag and setting --skip_sdk_update_check at runtime, but it still fails with the following error:
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
EDIT: Here's the complete command and error output:
$ dev_appserver.py helloworld/
INFO 2012-02-20 20:00:19,712 py_zipimport.py:148] zipimporter('/Library/Python/2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.6-fat.egg', 'MySQLdb/')
WARNING 2012-02-20 20:00:19,784 rdbms_mysqldb.py:94] The rdbms API is not available because the MySQLdb library could not be loaded.
Warning: You are using a Python runtime (2.6) that is more recent than the production runtime environment (2.5). Your application may use features that are not available in the production environment and may not work correctly when deployed to production.
INFO 2012-02-20 20:00:19,859 appengine_rpc.py:159] Server: appengine.google.com
WARNING 2012-02-20 20:00:19,874 dev_appserver.py:3396] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
Traceback (most recent call last):
File "/usr/local/bin/dev_appserver.py", line 99, in <module>
run_file(__file__, globals())
File "/usr/local/bin/dev_appserver.py", line 95, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 692, in <module>
sys.exit(main(sys.argv))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 656, in main
persist_logs=persist_logs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 3594, in CreateServer
server = HTTPServerWithScheduler((serve_address, port), handler_class)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 3622, in __init__
request_handler_class)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 400, in __init__
self.server_bind()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 411, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
The default behavior is to bind to 127.0.0.1, which is resolved to "localhost" by looking it up on /etc/hosts (or vice-versa). Try forcing it to bind to 127.0.0.1:8080 by starting it as "dev_appserver.py helloworld -a 127.0.0.1 -p 8080" or bind it to all local addresses with "dev_appserver.py helloworld -a 0.0.0.0 -p 8080" and see what happens.

Categories

Resources