psiTurk: AttributeError: 'Process' object has no attribute 'get_connections' - python-2.7

Before I begin, let me give the disclaimer that I'm very new at this sort of thing, that my explanation may not be too coherent, and I have no ability to separate what might and might not be important.
I'd like to run psiTurk. But because psiturk doesn't work on Windows, I'm using Openshift to run Python, with psiturk inside of that. I've gotten Openshift working using PuTTY, and have gotten as far as launching the psiTurk shell. But even when I enter the command to turn the server on, the server remains off with the following error message.
[psiTurk server:off mode:sdbx #HITs:0]$ server on
Experiment server launching...
Now serving on myurl.rhcloud.com
Traceback (most recent call last):
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/cmd2.py", line 789, in onecmd_plus_hooks
stop = self.postcmd(stop, statement)
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/psiturk/psiturk_shell.py", line 205, in postcmd
self.color_prompt()
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/psiturk/psiturk_shell.py", line 571, in color_prompt
server_status = self.server.is_server_running()
File "/var/lib/openshift/[my SSH]/python/virtenv/lib/python2.7/site-packages/psiturk/experiment_server_controller.py", line 144, in is_server_running
psiturk_exp_ports = [process[0].laddr[1] for process in [psutil.Process(int(pid)).get_connections() for pid in output]]
AttributeError: 'Process' object has no attribute 'get_connections'
'Process' object has no attribute 'get_connections'
Any help would be much appreciated.

Seems like standard pip install psiturk installs a version of the psutil library that's not compatible with psiturk. What worked for me was installing directly from git:
pip install git+git://github.com/NYUCCL/psiTurk.git#master
See this PR for details: https://github.com/NYUCCL/psiTurk/pull/192
Also, it's best to make a virtualenv to avoid problems with already-installed packages.

Related

Problem when downloading Google CRMint: AttributeError: module 'appcli' has no attribute 'entry_point'

I am trying to install CRMint following these instructions: https://google.github.io/crmint/docs/quickstart/cloudshell.md
When I tried to run to check if I have installed it
crmint --help
The following error appeared
Traceback (most recent call last):
File "/home/user/crmint/.venv/bin/crmint", line 33, in <module>
sys.exit(load_entry_point('crmint', 'console_scripts', 'crmint')())
File "/home/user/crmint/.venv/bin/crmint", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.9/importlib/metadata.py", line 79, in load
return functools.reduce(getattr, attrs, module)
AttributeError: module 'appcli' has no attribute 'entry_point'
Could someone help me on that? Thank you in advance.
I tried uninstalling and installing 'appcli', but it still didn't work.
This was around the same time that CRMint was upgraded to it's newest architecture, CRMint 3.0. This was a temporary bug that was impacting deployment, however, the current architecture deployment has been tested and should be working quiet reliably.
Sorry for the inconvenience. Let me know if you have other questions!

Failure to install Python win32 libraries?

Any ideas? I don't have Python in the path & the company won't allow it. I wouldn't expect it to make a difference to a well written installer, but mention it just in case.
H:\code\testgen\pywin32-220>c:\Python27\python.exe --version
Python 2.7.11
H:\code\testgen\pywin32-220>c:\Python27\python.exe setup.py -q install
Building pywin32 2.7.220.0
Traceback (most recent call last):
File "setup.py", line 1944, in <module>
""" % dirs).split(),
File "setup.py", line 594, in __init__
if os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")):
File "c:\Python27\lib\ntpath.py", line 65, in join
result_drive, result_path = splitdrive(path)
File "c:\Python27\lib\ntpath.py", line 115, in splitdrive
if len(p) > 1:
TypeError: object of type 'NoneType' has no len()
Despite this post was asked 3 months ago, I faced the same issue today. I found a solution in the end so I would like to share it here. Hope it is still useful.
I found in another post here:
https://www.quora.com/I-tried-to-install-PyWin32-for-Python-2-7-at-Python-for-Windows-Extensions-but-it-did-not-work-How-can-I-install-PyWin32
to install from the wheel distribution instead.
In case you have the same connection problem with pip like me, please download the source of wheel via its git repo:
https://bitbucket.org/pypa/wheel/downloads (choose the version you like, latest probably best). Then install it using
pip install <<_path_to_the_zip_file_downloaded_>>

Does Behave (BDD) work with Python 3.4?

I am using Behave (BDD for Python) and have been trying to enable JUnit output without success. After troubleshooting, I realized that I am getting the following error message only when using Python 3.4:
/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 "/Users/myusername/Documents/Programming/Selenium Programming/GMail Project/GMailTests.py"
Traceback (most recent call last):
File "/Users/myusername/Documents/Programming/Selenium Programming/GMail Project/GMailTests.py", line 62, in <module>
config = Configuration()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/behave/configuration.py", line 481, in __init__
load_configuration(self.defaults, verbose=verbose)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/behave/configuration.py", line 394, in load_configuration
defaults.update(read_configuration(filename))
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/behave/configuration.py", line 348, in read_configuration
result[dest] = cfg.get('behave', dest, use_raw_value)
TypeError: get() takes 3 positional arguments but 4 were given
When I update my project to use Python 2.7 instead, everything works fine.
Here is an important note: this is only causing trouble when I enable the JUnit output in the behave.ini config file. If I take the two lines below out of the config, everything goes fine. Unfortunately, I need to enable JUnit output for my project:
[behave]
junit=true
junit_directory=./JunitReports
If you know of any way I could make this work with Python 3.4, I'd love to know about it. Thanks in advance.
Changing the first line in the
script: /usr/local/bin/behave
to: #!/usr/local/bin/python3 #you might want to run which python3
resolved the issue
Looks like I answered my own question in my last comment. I just wanted to close the thread and provide an official answer as of 8/13/2014: behave is not fully supported on Python3.4, and even though most of it works fine when installed using pip3 install behave, the JUnit output option does not function.
There is a known issue for it that has been documented here.
Use behave-1.2.5.
Many Python3/Unicode related problems were fixed in this release. The tests run just fine on the CI server with Python 3.4.

Cannot create virtualenv in python 2.7

I'm trying to create a virtualenv with the following command:
$ virtualenv env --distribute
and I am getting the following message:
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.8.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1054, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 655, in install_pip
filter_stdout=_filter_setup)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/nigelra/Thero...blog/venv/bin/python -x /Users/nigelra/Thero...env/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz failed with error code 2
I'm not particularly adept at reading OSX error messages. Would someone be willing to lend their knowledge to solve this problem?
For anyone else who gets error code 2 in the future here is how I dealt with it.
I never figured out which problem made the fix (there were a lot of problems) but I can outline the steps I took to cleaning up my computer.
I followed this guide to setting up my Python environment "right" http://docs.python-guide.org/en/latest/starting/install/osx/
I encounter a ton of errors when I did $ brew doctor
I laboriously got rid of every warning and error using google as my guide.
Many of the folder permissions had to be changed.
Eventually I was able to set up a virtualenv after a re installation of most everything.
Hope this helps anyone who encounters the same mess I did.

Weird behavior causes my runserver to not respond

I've been having some very weird problems. Yesterday I updated my master branch on a project and after that, when I tried to do manage.py runserver the runserver wouldn't serve any page. I had to ctrl + c to exit the server and I would later receive this message.
Exception happened during processing of request from ('127.0.0.1', 53975)
Unhandled exception in thread started by <function inner_run at 0x2ec8488>
Traceback (most recent call last):
File "/home/marco/virtualenvs/designersenv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 60, in inner_run
run(addr, int(port), handler)
File "/home/marco/virtualenvs/designersenv/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 721, in run
httpd.serve_forever()
File "/usr/lib/python2.7/SocketServer.py", line 227, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python2.7/SocketServer.py", line 286, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 342, in handle_error
import traceback
ImportError: No module named traceback
I found out by experimentation that erasing the database(sqlite) and recreating it with syncdb and migrate removed the issue, but once I add something to the models via the admin page, I would get the same error again, no pages would be served.
I also noticed that when this was going on, python starting to occupy around 40-60% of my CPU and RAM. I later noticed on the project folder, where database.db is located, a database.db-journal file would be created every 2-3 seconds, get deleted and then reappear. Googling didn't bring me any results so I am laying my hands on SO wisdom. Thanks.
I can see you are running in a virtual enviroment. It's possible that it became corrupted while downloading. I would recreate it from scratch.
Also, check in that enviroment shell if you can import traceback and check outside the enviroment too. It may give you some clues.
disclaimer: this answer is 90% intuition, sorry :/
A couple months late but anyway, here is what my problem was:
A django app was messing up and getting stuck in a bug. I believe it was Django Cache Bot.
Cheers.