CherryPy running tut01 file on Windows - python-3.x

Bit of info: Python 3.2.3,
Cherrypy version 3.2.2. Windows 7 64-bit.
Installed Cherrypy, set up PATH with the right Python directory, etc. However, whenever I run the tutorial file (tut01, Hello world) or any other python file with the same code, I get the following output:
F:\Code>python helloworld.py [29/Nov/2012:22:37:22] ENGINE Listening
for SIGTERM. [29/Nov/2012:22:37:22] ENGINE Bus STARTING CherryPy
Checker: The Application mounted at '' has an empty config.
[29/Nov/2012:22:37:22] ENGINE Started monitor thread
'_TimeoutMonitor'. [29/Nov/2012:22:37:22] ENGINE Started monitor
thread 'Autoreloader'. [29/Nov/2012:22:37:22] ENGINE Error in 'start'
listener > Traceback (most recent call last): File
"C:\Python32\lib\site-packages\cherrypy\process\wspbus.py", line 197,
in publish
output.append(listener(*args, **kwargs)) File "C:\Python32\lib\site-packages\cherrypy_cpserver.py", line 150, in
start
self.httpserver, self.bind_addr = self.httpserver_from_self() File "C:\Python32\lib\site-packages\cherrypy\_cpserver.py", line 140,
in https erver_from_self
from cherrypy import _cpwsgi_server File "C:\Python32\lib\site-packages\cherrypy_cpwsgi_server.py", line 7, in
from cherrypy import wsgiserver File "C:\Python32\lib\site-packages\cherrypy\wsgiserver__init__.py", line
14, in
exec('from .wsgiserver3 import *') File "", line 1, in ImportError: No module named wsgiserver3
[29/Nov/2012:22:37:22] ENGINE Shutting down due to error in start
listener: Traceback (most recent call last): File
"C:\Python32\lib\site-packages\cherrypy\process\wspbus.py", line 235,
in start
self.publish('start') File "C:\Python32\lib\site-packages\cherrypy\process\wspbus.py", line 215,
in publish
raise exc cherrypy.process.wspbus.ChannelFailures: ImportError('No module named wsgiserver 3',)
[29/Nov/2012:22:37:22] ENGINE Bus STOPPING [29/Nov/2012:22:37:22]
ENGINE HTTP Server None already shut down [29/Nov/2012:22:37:22]
ENGINE Stopped thread 'Autoreloader'. [29/Nov/2012:22:37:22] ENGINE
Stopped thread '_TimeoutMonitor'. [29/Nov/2012:22:37:22] ENGINE Bus
STOPPED [29/Nov/2012:22:37:22] ENGINE Bus EXITING
[29/Nov/2012:22:37:22] ENGINE Bus EXITED
And pointing browser to localhost:8080 does nothing, when it should show Hello World.
Pretty sure I did everything correctly according to the installation guide on the Cherrypy website. Not entirely sure how to fix it, but I'm guessing it has something to do with the import errors. Has anyone else had success with installing cherrypy on windows for python3?
Found a solution: https://bitbucket.org/cherrypy/cherrypy/issue/1110/cherrypy-322win32exe-installer-didnt
The original installer was missing the wsgiserver3 module, which was needed for it to work on Python 3.x. The above installer should fix the issue.

I struggled with this, there is a simple solution:
clone the repository to your local machine.
navigate to the root folder and execute the following command: python setup.py install
It is mentioned in the README.txt here in the official source repo.

Just to notice that this is a answered question, quoting rashdanml:
Found a solution: https://bitbucket.org/cherrypy/cherrypy/issue/1110/cherrypy-322win32exe-installer-didnt?
The original installer was missing the wsgiserver3 module, which was needed for it to work on Python 3.x. The above installer should fix the issue.

Related

How can I fix flow server error on windows? crashes with wierd error message

I am trying to use Flow-Type in a react native project by using npm package flow-bin. but when I try to run flow, it gives an error Unix.Unix_error(Unix.ENOTSOCK, "select", ""). I have been looking for a solution but no luck so far. Following are the details of the error. Plus; I have tried to completely uninstall nodejs and installed it again but still the same result.
Any help would be highly appreciated!!
node --version
v15.9.0
npm --version
7.5.3
Operating System
Windows 10 Pro 64bit
Build 20H2
Steps to Error
npm init
npm i -D flow-bin
add flow to script in package.json
npm run flow init
npm run flow
ERROR
Error Details
PowerShell Screenshot
Logs
[2021-02-24 03:44:28.921] argv=E:\LearningLab\Work\TechnicianApp\node_modules\flow-bin\flow-win64-v0.135.0\flow.exe start --flowconfig-name .flowconfig --temp-dir C:\Users\ajplu\AppData\Local\Temp\flow E:\LearningLab\Work\TechnicianApp
[2021-02-24 03:44:28.921] lazy_mode=off
[2021-02-24 03:44:28.921] arch=types_first
[2021-02-24 03:44:28.921] abstract_locations=off
[2021-02-24 03:44:28.921] max_workers=4
[2021-02-24 03:44:28.921] debug=false
[2021-02-24 03:44:28.922] Initializing Server (This might take some time)
[2021-02-24 03:44:28.922] executable=E:\LearningLab\Work\TechnicianApp\node_modules\flow-bin\flow-win64-v0.135.0\flow.exe
[2021-02-24 03:44:28.923] version=0.135.0
[2021-02-24 03:44:28.923] No saved state available
[2021-02-24 03:44:28.924] Parsing
Monitor died unexpectedly
Monitor Logs
Feb 24 03:44:28.796 [info] argv=E:\LearningLab\Work\TechnicianApp\node_modules\flow-bin\flow-win64-v0.135.0\flow.exe start --flowconfig-name .flowconfig --temp-dir C:\Users\ajplu\AppData\Local\Temp\flow E:\LearningLab\Work\TechnicianApp
Unix.Unix_error(Unix.ENOTSOCK, "select", "")
Raised by primitive operation at file "src/common/lwt/lwtInit.ml", line 36, characters 18-46
Called from file "list.ml", line 117, characters 24-34
Called from file "src/common/lwt/lwtInit.ml", line 34, characters 8-206
Called from file "src/unix/lwt_engine.ml", line 344, characters 8-19
Called from file "src/unix/lwt_main.ml", line 33, characters 4-78
Called from file "src/common/lwt/lwtInit.ml", line 129, characters 4-135
Called from file "src/hack_forked/utils/sys/daemon.ml", line 150, characters 4-20
Found this reason.
It turned out somehow Astril VPN was causing flow server to crash. even though it was only installed and not running. After uninstalling Astril flow works like a charm.
If someone encounters a similar problem, then they should try to uninstall their VPN/Proxy software. I am not sure if other VPN software can cause this issue because I have only used Astril.

Getting import _rd_kafka error in all docker images while trying to connect to kafka via pykafka

HI i tried with multiple docker images like Ubuntu and python:3.8-alpine etc.. and everywhere I am getting an error as below while trying to connect to my kafka cluster (2.7) via pykafka library.
Environment info:
kafka server : 2.7 (installed via strimzi kafka in EKS)
kafka clinet: pykafka (2.8.0)
python version: 3.8, 3.7 in all version i get same error
Note: This error happens only when the code run's inside the container when I run outside i.e directly from my machine then it works fine
INFO:pykafka.topic:Could not load pykafka.rdkafka extension.
DEBUG:pykafka.topic:Traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pykafka/topic.py", line 43, in <module>
from . import rdkafka
File "/usr/local/lib/python3.8/site-packages/pykafka/rdkafka/__init__.py", line 1, in <module>
from .producer import RdKafkaProducer
File "/usr/local/lib/python3.8/site-packages/pykafka/rdkafka/producer.py", line 7, in <module>
from . import _rd_kafka
ImportError: cannot import name '_rd_kafka' from partially initialized module 'pykafka.rdkafka' (most likely due to a circular import) (/usr/local/lib/python3.8/site-pac
INFO:pykafka.cluster:Broker version is too old to use automatic API version discovery. Falling back to hardcoded versions list.
DEBUG:pykafka.cluster:Updating cluster, attempt 1/3
DEBUG:pykafka.connection:Connecting to kafka-kafka-bootstrap.kafka:9093
INFO:pykafka.connection:Attempt 0: failed to connect to kafka-kafka-bootstrap.kafka:9093
INFO:pykafka.connection:[Errno 2] No such file or directory
INFO:pykafka.connection:Retrying in 300ms.
INFO:pykafka.connection:Attempt 1: failed to connect to kafka-kafka-bootstrap.kafka:9093
INFO:pykafka.connection:[Errno 2] No such file or directory
INFO:pykafka.connection:Retrying in 300ms.
INFO:pykafka.connection:Attempt 2: failed to connect to kafka-kafka-bootstrap.kafka:9093
INFO:pykafka.connection:[Errno 2] No such file or directory
INFO:pykafka.connection:Retrying in 300ms.
WARNING:pykafka.broker:Failed to connect to broker at kafka-kafka-bootstrap.kafka:9093. Check the `listeners` property in server.config.
This works with centos docker image, but not sure why did not work with other images like ubunut python3.8-alpine etc..

Index out of error in while deploying flask app using ngrok

I have created a server using Flask for a demonstration of my ML model. I was running it on Google Colab and using flask-ngrok for tunneling. It was working properly, but suddenly it stopped working today and is showing this error:
=> loading checkpoint './semi_supervised_model_3/ckpt_epoch_10.00.pth'
=> loaded checkpoint './semi_supervised_model_3/ckpt_epoch_10.00.pth' (epoch 10.0)
* Serving Flask app "demo_Server" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 1182, in run
self.function(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/dist-packages/flask_ngrok.py", line 70, in start_ngrok
ngrok_address = _run_ngrok()
File "/usr/local/lib/python3.6/dist-packages/flask_ngrok.py", line 38, in _run_ngrok
tunnel_url = j['tunnels'][0]['public_url'] # Do the parsing of the get
IndexError: list index out of range
What is the meaning of this error? Why is it coming even when I didn't change anything?
My problem got solved when I terminated the current session. In the new session, I reinstalled flask-ngrok and it worked fine.

Python 3.6.4 can connect to Slack locally (via slackclient) but in Azure it cannot

Python 3.6.4 (32 bit x86) using slackclient locally connects to the RTM API and is able to listen in on slack channel changes. That same code running in Azure (64 bit AMD) does not work.
I've made sure that the Azure python install is as close to my local machine as possible. There are a few package discrepancies (see below) though this should not be the issue since these are not being used:
Azure vs. Local Machine
* numpy 1.15.3 vs. numpy 1.16.0
* pyodbc 4.0.24 vs. pyodbc 4.0.25
* pytz 2018.7 vs. pytz 2018.9
* setuptools 38.5.2 vs. setuptools 28.8.0
I've looked at the following links though I am not sure they will help. Some of the instructions for setting up a proxy in Azure are no longer valid (off by several steps). Recently Azure stopped serving a web app of mine (C#/ASP) when I changed the (totally unrelated Python) setting below.
Application settings->General settings->Python version (from Off to 3.4)
It was a real pain to get it back. I think that I will need a proxy though I would imagine Azure should provide better instructions for this. I am somewhat of an Azure newb though not new enough to start changing things willy nilly!
make Python 3.x Slack (slackclient) use a corporate proxy
Custom Slack Bot cannot connect
https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/application-proxy-configure-connectors-with-proxy-servers
https://learn.microsoft.com/en-us/azure/azure-functions/functions-proxies
import time, logging, os
from slackclient import SlackClient
from datetime import datetime
def main():
#proxies = dict(https="proxy.azure.com:443", http="proxy.azure.com:443")
sc = SlackClient(BOT_TOKEN)
CHANNEL_ID = "some channel id"
logger.debug("Listening to channel '{0}' with id '{1}' for the following actions: ".format(CHANNEL_NAME, CHANNEL_ID))
if sc.rtm_connect():
logger.debug("Connected to Slack!")
while True:
# Read latest messages
# If activity is in CHANNEL_ID do something
else:
logger.debug("Couldn't connect to slack")
On my local machine I get the following (I cut out some of the code):
DEBUG - Listening to channel 'news' with id 'CFDQ3BXYZ' for the following actions:
DEBUG - message_replied
DEBUG - message_deleted
DEBUG - message_changed
DEBUG - Connected to Slack!
However, in Azure, I get the following:
DEBUG - Listening to channel 'news' with id 'CFDQ3BXYZ' for the following actions:
DEBUG - message_replied
DEBUG - message_deleted
DEBUG - message_changed
DEBUG - Couldn't connect to Slack!
The Azure error message is as follows:
01-14-2019 23:17:26, urllib3.connectionpool, DEBUG, Starting new HTTPS connection (1): slack.com:443
01-14-2019 23:17:26, urllib3.connectionpool, DEBUG, https://slack.com:443 "POST /api/rtm.start HTTP/1.1" 200 18349
01-14-2019 23:17:26, slackclient.client, WARNING, Failed RTM connect
Traceback (most recent call last):
File "D:\home\python364x64\lib\site-packages\slackclient\server.py", line 192, in connect_slack_websocket
http_proxy_auth=proxy_auth,
File "D:\home\python364x64\lib\site-packages\websocket\_core.py", line 511, in create_connection
websock.connect(url, **options)
File "D:\home\python364x64\lib\site-packages\websocket\_core.py", line 220, in connect
options.pop('socket', None))
File "D:\home\python364x64\lib\site-packages\websocket\_http.py", line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "D:\home\python364x64\lib\site-packages\websocket\_http.py", line 164, in _open_socket
sock.setsockopt(*opts)
OSError: [WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\home\python364x64\lib\site-packages\slackclient\client.py", line 140, in rtm_connect
self.server.rtm_connect(use_rtm_start=with_team_state, **kwargs)
File "D:\home\python364x64\lib\site-packages\slackclient\server.py", line 159, in rtm_connect
self.connect_slack_websocket(self.ws_url)
File "D:\home\python364x64\lib\site-packages\slackclient\server.py", line 200, in connect_slack_websocket
raise SlackConnectionError(message=str(e))
slackclient.server.SlackConnectionError: [WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
01-14-2019 23:17:26, Slack_bot_listener, DEBUG, Couldn't connect to slack
Any help will be greatly appreciated!
It appears that WebJobs are restricted to port 80 only. So there is no way to open up ports, etc. on Azure WebJobs at least at this time (see article/post below). So it appears that a VM or some other route is the way to proceed.
Can I open ports on Azure Websites?

Hello world failing

I've just installed python 3.2.1 (32-bit) and cherrypy 3.2.1 (CherryPy-3.2.1.win32-py3.exe) on my Windows 7 box and have tried the hello world example (executed via PyScripter) but it hangs after the Engine bus STARTED message.
If I try to start it via the python.exe, I get the following log:
C:\Program Files (x86)\Python32>python hello.py
[24/Jul/2011:16:24:03] ENGINE Listening for SIGTERM.
[24/Jul/2011:16:24:03] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.
[24/Jul/2011:16:24:03] ENGINE Started monitor thread 'Autoreloader'.
[24/Jul/2011:16:24:03] ENGINE Started monitor thread '_TimeoutMonitor'.
[24/Jul/2011:16:24:03] ENGINE Serving on 127.0.0.1:8080
[24/Jul/2011:16:24:03] ENGINE Bus STARTED
Exception in thread CP Server Thread-4:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 693, in read_request_headers
read_headers(self.rfile, self.inheaders)
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 202, in read_headers
raise ValueError("Illegal end of headers.")
ValueError: Illegal end of headers.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 1024, in communicate
req.parse_request()
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 578, in parse_request
success = self.read_request_headers()
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 696, in read_request_headers
self.simple_response("400 Bad Request", ex.args[0])
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 840, in simple_response
status = str(status)
TypeError: 'tuple' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python32\lib\threading.py", line 736, in _bootstr
ap_inner
self.run()
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 1174, in run
conn.communicate()
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 1080, in communicate
req.simple_response("500 Internal Server Error", format_exc())
File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws
giserver3.py", line 840, in simple_response
status = str(status)
TypeError: 'tuple' object is not callable
What am I missing?
Code:
import cherrypy
class HelloWorld:
def index(self):
return "Hello world"
index.exposed = True
cherrypy.quickstart(HelloWorld())
EDIT: Bonus-info: I've tried various things to remedy the situation with no result. Installing the 64-bit version of python didn't help as cherrypy doesn't support 64-bit (unless, I'm mistaken). I've tried re-installing both python and the cherrypy packages, and I've tried deactivating all other things that might block it (IIS). All to no avail :-(
EDIT2: Second bonus - everything works if I install it with python 2.7.2, so seems it is only a problem with 3.x (I've tried 3.0.1 as well - same problem)
I have encountered two errors:
1 - open your browser before starting the script, so you'll not have any problem.
2 - if you use a personal firewall or an antivirus that handles HTTP protection, be sure he is not protecting the 8080 port, for example ESET Antivirus will not let you use the 8080 and CherryPy will say that the port is not free.

Resources