MPLD3 not showing graph in browser - python

I'm using Google Chrome on Mac OS X 10.11.4. Im trying to run this example from the mpld3 library. I read that mpld3 does not work on python 3.5,
The mpld3 project is compatible with Python 2.6-2.7 and 3.3-3.4.
so I created a 3.4 environment using:
conda create -n py34 python=3.4 anaconda
When running the script I get the following error:
Exception happened during processing of request from ('127.0.0.1', 52484)
Traceback (most recent call last):
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/socketserver.py", line 305, in _handle_request_noblock
self.process_request(request, client_address)
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/socketserver.py", line 331, in process_request
self.finish_request(request, client_address)
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/socketserver.py", line 344, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/socketserver.py", line 673, in __init__
self.handle()
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/http/server.py", line 401, in handle
self.handle_one_request()
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/http/server.py", line 389, in handle_one_request
method()
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/site-packages/mpld3/_server.py", line 38, in do_GET
self.wfile.write("<html><head>"
File "/Users/Neill/anaconda/envs/py34/lib/python3.4/socket.py", line 398, in write
return self._sock.send(b)
TypeError: 'str' does not support the buffer interface
I also made sure that the latest version of mpld3 is installed. The local server then displays a blank page. Chrome's developer tools also report no errors. Does anyone have an idea what the problem might be?

Related

Werkzeug server is shutting down in Django application

after updating the Werkzeug version from 2.0.3 to 2.1.0, I keep getting errors every time I run the server, and here is the error log:
Exception happened during processing of request from ('127.0.0.1', 44612)
Traceback (most recent call last):
File "/usr/lib/python3.8/socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.8/socketserver.py", line 747, in __init__
self.handle()
File "/home/oladhari/.virtualenvs/reachat/lib/python3.8/site-packages/werkzeug/serving.py", line 363, in handle
super().handle()
File "/usr/lib/python3.8/http/server.py", line 427, in handle
self.handle_one_request()
File "/usr/lib/python3.8/http/server.py", line 415, in handle_one_request
method()
File "/home/oladhari/.virtualenvs/reachat/lib/python3.8/site-packages/werkzeug/serving.py", line 243, in run_wsgi
self.environ = environ = self.make_environ()
File "/home/oladhari/.virtualenvs/reachat/lib/python3.8/site-packages/django_extensions/management/commands/runserver_plus.py", line 326, in make_environ
del environ['werkzeug.server.shutdown']
KeyError: 'werkzeug.server.shutdown'
this exception keep appearing while incrementing by 2 ( ('127.0.0.1', 44612) -> ('127.0.0.1', 44628) and the server crash
checking the changes log, I have found this detail:
Remove previously deprecated code. #2276
Remove the non-standard shutdown function from the WSGI environ when running the development server. See the docs for alternatives.
here is the link to the changes log
it asks to check the documentation for alternatives but can not find any
please let me know how I would resolve this error, thank you
NB: my python version is 3.8
Literally just ran into this today. According to their (git repo issue 1715) and assuming you are running runserver_plus, there are three options that worked for some users. The first worked for me:
Not altering your files and adding the option --keep-meta-shutdown. My full command looks like python manage.py runserver_plus --cert-file /path/to/cert.pem --key-file /path/to/key.pem --keep-meta-shutdown localhost:9000
Comment out open lines 325 and 326 under your runserver_plus.py
Upgrading python to 3.10
Hope this helps!
The Django-extensions issue for this recommends running runserver_plus with the --keep-meta-shutdown argument.
Alternatively, you can just downgrade Werkzeug to 2.0.* until this is fixed:
pip install Werkzeug==2.0.*
If using a requirements.txt file, use the following:
Werkzeug==2.0.*

Windows: How to run a shell script out of a simple CGI python server

I have made a python Srver using http.server
python -m http.server --cgi 8000
Server is running and i am able to run a python script on it. I am trying to run shell file with similar content.
I think i am not bale to make the shell file executable. Lookign for soemthing like chmod +x filename.sh in windows.
Ubuntu Equivalent link: https://askubuntu.com/questions/229589/how-to-make-a-file-e-g-a-sh-script-executable-so-it-can-be-ran-from-terminal
Currently i am getting this error:
Content-type text/htmlException happened during processing of request from ('127.0.0.1', 1659)
Traceback (most recent call last):
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 313, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 341, in process_request
self.finish_request(request, client_address)
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 681, in __init__
self.handle()
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 422, in handle
self.handle_one_request()
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 410, in handle_one_request
method()
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 645, in do_GET
f = self.send_head()
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 953, in send_head
return self.run_cgi()
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 1161, in run_cgi
env = env
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
< h1 >Hello World< /h1 >
Updated
Content of Python file:
#!/usr/bin/env python
print("Content-type text/html")
print("")
print("< h1 > Hello World < / h1 >")`
Output:(on browser screen)
Hello World
Shell File Content
#!/bin/bash
echo "Content-type text/html"
echo ""
echo "< h1 >Hello World< /h1 >" `
Output:
Above mentioned error.
Want the similar output Hello World.
In windows there are no bash-scripts. You only have .bat-Files with very limited syntax. If you try to run your script as filename.sh windows tries to find a program associated with the extension .sh and fails. You should rename your file to filename.bat.

Python socket server errors upon PyCharm arcpy import - what have I not set up?

I am having trouble with setting up my development environment (the latest release Community build of PyCharm). I have been using the previous version to write python scripts for ArcGIS processing. To do this you need to import the ArcGIS python API - arcpy. This has always been fine but now I can't seem to access arcpy directly.
I have the ArcGIS location added to my python path, to my project settings paths and can instantiate an instance of an arcpy object but trying to interact with top level methods or classes generates a socket server error (below). For example from the interactive prompt:
>> import arcpy - will work
but typing
>> arcpy. - will instantly generate
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 295, in _handle_request_noblock
Exception happened during processing of request from ('127.0.0.1', 59487)
self.process_request(request, client_address)
File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 653, in __init__
self.finish()
File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 712, in finish
self.wfile.close()
File "C:\Python27\ArcGIS10.3\lib\socket.py", line 279, in close
self.flush()
File "C:\Python27\ArcGIS10.3\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in your host machine
However - if I ignore this and instantiate and instance of a map document for example
>>import arcpy
>>fullpath = r'C:\Temp\some.mxd' # where this is a valid ESRI map doc
>> my_mapdoc_object = arcpy.mapping.MapDocument(fullpath)
I can now interact with the object.
What am I doing wrong with setting up my environment?
Appears to be a docstring issue that PyCharm is tripping over.
Within arcpy, within the docstring of one of the tool functions, there is an escape character, specifically \a, in a data path. If that is corrected, the error goes away.

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

Broken anydbm.py on ubuntu 10.04 with python 2.6.5?

When trying to run django-celery with beat scheduler:
bin/django celeryd -B --settings=app.development --loglevel=INFO
I got this exception:
Process Beat:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/multiprocessing/process.py", line 237, in _bootstrap
self.run()
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 388, in run
self.service.start(embedded_process=True)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 318, in start
humanize_seconds(self.scheduler.max_interval)))
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 358, in scheduler
self._scheduler = self.get_scheduler()
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 350, in get_scheduler
lazy=lazy)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/utils/__init__.py", line 362, in instantiate
return get_cls_by_name(name)(*args, **kwargs)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 270, in __init__
Scheduler.__init__(self, *args, **kwargs)
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 146, in __init__
self.setup_schedule()
File "/home/user/eggs/celery-2.1.1-py2.6.egg/celery/beat.py", line 273, in setup_schedule
self._store = self.persistence.open(self.schedule_filename)
File "/usr/lib/python2.6/shelve.py", line 239, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib/python2.6/shelve.py", line 223, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
AttributeError: 'module' object has no attribute 'open'
My own investigation led me to discovering that the anydbm python module found in
/usr/lib/python2.6/anydbm.py
is an empty file. But the python2.6.5 doc says there is an
anydbm.open(filename[, flag[, mode]])
method.
Am I missing something? I think the anydbm [ubuntu] python module is broken.
I'm using:
Ubuntu 10.04
Python 2.6.5
django-celery 2.1.1
celery installed with buildout
If /usr/lib/python2.6/anydbm.py is an empty file for you, then yes, your installation is broken. /usr/lib/python2.6/anydbm.py is the correct file, with contents, on my Ubuntu 10.04 system, with python2.6_2.6.5-1ubuntu6 installed. You'll want to make sure you have the latest package installed, and possibly reinstall it.

Categories

Resources