Getting “pika.exceptions.ConnectionClosed” error while using rabbitmq in python - python

I am trying to use rabbitmq in python.
My code is:
import pika
if __name__ == '__main__':
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
I am running this file using:
python3 test.py
Error Signature:
Traceback (most recent call last):
File "Test.py", line 4, in <module>
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pika/adapters/blocking_connection.py", line 339, in __init__
self._process_io_for_connection_setup()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pika/adapters/blocking_connection.py", line 374, in _process_io_for_connection_setup
self._open_error_result.is_ready)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pika/adapters/blocking_connection.py", line 395, in _flush_output
raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed
Already referred this , but i dont have any sleep in my code.
Not really sure what could go wrong.
Please let me know if I am missing something obvious.

The issue was with rabbitmqctl. Reconfigured it, Restarted service, and the issue is fixed.
Make sure rabbitmqctl is installed(if installed, uninstall it and re-install;when you just enter rabbitmqctl, it should display the help)
rabbitmqctl start_app
TIP: I tried installing first using 'brew',but for some reason, I was not able to get it right. So installed, rabbitmqctl as a separate package and added to PATH

Related

atbswp python file is not running on crontabs

atbswp is a software that help you automate all the mouse clicks and movements and keyboards keys so you can automate everything u do and repeat it or replay it
and by using crontab you can schedule it so you can run automated sequence at specific time
the app extracts a python file
and you run it inside the app or in terminal without the need of the app
the problem is
when i run it in terminal it runs ok
when i put it in crontab to run it doesnt run and i got errors in the crontab log file
i really need help it is something amazing for everyone i think
this is the cron log error
Traceback (most recent call last):
File "/home/zultan/bot1", line 4, in
import pyautogui
File "/home/zultan/.local/lib/python3.8/site-packages/pyautogui/init.py", line 241, in
import mouseinfo
File "/home/zultan/.local/lib/python3.8/site-packages/mouseinfo/init.py", line 223, in
_display = Display(os.environ['DISPLAY'])
File "/usr/lib/python3.8/os.py", line 675, in getitem
raise KeyError(key) from None
KeyError: 'DISPLAY'
i found the solution for everybody
put this
in the crontab -e
DISPLAY=:0
XAUTHORITY=/run/user/1000/gdm/Xauthority

I can´t install Anaconda on Linux

When I try to install Anaconda on Linux, I get to this point:
Anaconda3 will now be installed into this location:
/home/jorge/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/jorge/anaconda3] >>>
PREFIX=/home/jorge/anaconda3
Unpacking payload ...
Then I receive the following error message:
concurrent.futures.process._RemoteTraceback:
'''
Traceback (most recent call last):
File "concurrent/futures/process.py", line 367, in _queue_management_worker
File "multiprocessing/connection.py", line 251, in recv
TypeError: __init__() missing 1 required positional argument: 'msg'
'''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "entry_point.py", line 69, in <module>
File "concurrent/futures/process.py", line 483, in _chain_from_iterable_of_lists
File "concurrent/futures/_base.py", line 598, in result_iterator
File "concurrent/futures/_base.py", line 435, in result
File "concurrent/futures/_base.py", line 384, in __get_result
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
[1770] Failed to execute script entry_point
What can I do? I was following all the instructions step by step
I had a similar problem where available storage (disk space) was only 1.2 GB. Please make sure that you have enough free storage space to install it. To check available space, type
df -h /home/
Did you verify the integrity of the installer's data? because it is a common error when downloading this corrupted or incomplete
since it is the previous step you have to do to make sure that the file is ok before executing the script.
This post helped me a lot for the first time I installed it.
https://www.digitalocean.com/community/tutorials/how-to-install-anaconda-on-ubuntu-18-04-quickstart

Python 2.7 - grammar-check 1.3.1 library: HTTP Error 400: Bad Request

I am trying to use the grammar-check 1.3.1 library for Python
I have installed it using the pip commands
$ pip install --upgrade 3to2
$ pip install --upgrade language-check
I also unzipped the LanguageTool file from this link and moved it to C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check
Then I tried to run a test program
import grammar_check
tool = grammar_check.LanguageTool('en-GB')
text = 'This are bad.'
matches = tool.check(text)
len(matches)
But I got this error:
Traceback (most recent call last):
File "grammar-checker-test.py", line 2, in <module>
tool = grammar_check.LanguageTool('en-GB')
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 196, in __init__
self._language = LanguageTag(language)
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 405, in __new__
return unicode.__new__(cls, cls._normalize(tag))
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 426, in _normalize
for language in get_languages())
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 485, in get_languages
languages = LanguageTool._get_languages()
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 286, in _get_languages
for e in cls._get_root(url, num_tries=1):
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 311, in _get_root
raise Error(u'{}: {}'.format(cls._url, e))
grammar_check.Error: http://127.0.0.1:8081: HTTP Error 400: Bad Request
How can I solve this error?
I had this error:
grammar_check.Error: http://127.0.0.1:8081:
I am not sure why you have to start server on your local machine as this piece of code does exactly that:
tool = grammar_check.LanguageTool('en-GB')
If you will have one more language_tool server running on 8081, then it will try to start server on port 8082 and if even that is busy on 8083 and then will fail (which was happening in my case).
Anyways for my error, I had to debug a lot and finally figured out that server was not able to run as my JAVA runtime environment was messed up.
The problem was that I wasn't running the LanguageTool server.
In order to do that I have to check if I have the LanguageTool folder (its version must be < 3.3, in my case it's the 2.2) inside my grammar_check folder.
Then using the cmd shell I have to move into this LanguageTool folder, which in my case is located in this path:
C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\LanguageTool-2.2
than, I have to run the server with this command
java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8081
and voilà grammar_check is working well

Unable to start pritunl after installation

I've installed pritunl on my VPS. Now I can't access to the web interface. It's not possible to start the service (Please have a look on the logs below).
There's a mariadb DB besides the mongodb which is included in pritunl, is it a problem? (I need the mariadb for other applications, thats why)
I followed the official guide for CentOS. It seems like there are some missing prerequisites, but actually I don't know.
Can someone help me out? :-)
Thanks!
Moejoe
pritunl logs
[undefined][2017-01-30 21:45:51,211][ERROR] Pritunl setup failed
Traceback (most recent call last):
File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/setup/__init__.py", line 68, in setup_db
setup_mongo()
File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/setup/mongo.py", line 65, in setup_mongo
serverSelectionTimeoutMS=MONGO_SOCKET_TIMEOUT,
File "/usr/lib/pritunl/lib/python2.7/site-packages/pymongo/mongo_client.py", line 345, in __init__
seeds.update(uri_parser.split_hosts(entity, port))
File "/usr/lib/pritunl/lib/python2.7/site-packages/pymongo/uri_parser.py", line 244, in split_hosts
raise ConfigurationError("Empty host "
ConfigurationError: Empty host (or extra comma in host list).
Traceback (most recent call last):
File "/usr/bin/pritunl", line 9, in <module>
load_entry_point('pritunl==1.26.1231.99', 'console_scripts', 'pritunl')()
File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/__main__.py", line 264, in main
setup.setup_db()
File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/setup/__init__.py", line 68, in setup_db
setup_mongo()
File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/setup/mongo.py", line 65, in setup_mongo
serverSelectionTimeoutMS=MONGO_SOCKET_TIMEOUT,
File "/usr/lib/pritunl/lib/python2.7/site-packages/pymongo/mongo_client.py", line 345, in __init__
seeds.update(uri_parser.split_hosts(entity, port))
File "/usr/lib/pritunl/lib/python2.7/site-packages/pymongo/uri_parser.py", line 244, in split_hosts
raise ConfigurationError("Empty host "
pymongo.errors.ConfigurationError: Empty host (or extra comma in host list).
I had exactly the same problem.
The only solution is to (temporaly) shut down apache:
Obviously sudo service httpd stop or on debian sudo service apache stop
After that, you should be able to finish the installation and start pritunl, and change the ports to not use 80 and 443, and finally restarting everything like a boss
For me that was like, in this order only
sudo pritunl set app.redirect_server false
sudo service pritunl stop
sudo service apache start
sudo service pritunl start

Can not run robotframework-ride properly

I have installed robotframework-ride on two PCs of mine. Everything works fine on one PC but could not have RIDE running on other PC.
I have the following installed on both PCs
- Python 2.7.8 on win32
- Robot framework 2.8.6
- wxPython 2.8.12.1
- robotframeowkr-ride-1.4.1b
When I tried to execute "python ride.py" on the second PC, I got a message:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide__init__.py", line 74, in main
run(inpath, not noupdatecheck, debug_console)
File "C:\Python27\lib\site-packages\robotide__init_.py", line 100, in run
ride = RIDE(inpath, updatecheck)
File "C:\Python27\lib\site-packages\robotide\application\application.py", line
41, in __init_
wx.App.init(self, redirect=False)
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py", line 7981
, in init
self.BootstrapApp()
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py", line 7555
, in _BootstrapApp
return _core.PyApp__BootstrapApp(args, *kwargs)
File "C:\Python27\lib\site-packages\robotide\application\application.py", line
49, in OnInit
self.namespace = Namespace(self.settings)
File "C:\Python27\lib\site-packages\robotide\namespace\namespace.py", line 41,
in init
self._set_pythonpath()
File "C:\Python27\lib\site-packages\robotide\namespace\namespace.py", line 62,
in _set_pythonpath
self._settings.get('installed robot version', None))
File "C:\Python27\lib\site-packages\robotide\namespace\robotlibraryloader.py",
line 35, in find_installed_robot_libraries
rf_file, rf_version = output.strip().split(', ')
ValueError: too many values to unpack
Use --help to get usage information.
Something more interesting is, if I uninstall robot framework from the second PC, I could execute "python ride.py" but of course there is no point doing this.
Anyone can help me out here?
With kind assistance from janne, I have solved this problem. The cause is for the first PC I installed the correct "robotframework", but for the second PC I managed to install a wrong module, "robot" instead of "robotframework". That was why RIDE was not working.
I am sorry for making such a silly mistake. A big thank you to janne for his help.
should use: pip install robotframework
should NOT use: pip install robot

Categories

Resources