Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with readline #173

Closed
john-guerra opened this issue Mar 11, 2015 · 13 comments
Closed

Problems with readline #173

john-guerra opened this issue Mar 11, 2015 · 13 comments

Comments

@john-guerra
Copy link

Hi I'm trying to run the example using psiturk but I'm getting this error:

$ psiturk
libedit version of readline detected.
readline will not be well behaved, which may cause all sorts
of problems for the psiTurk shell. We highly recommend installing
the gnu version of readline by running "sudo pip install gnureadline".
Note: "pip install readline" will NOT work because of how the OSX
pythonpath is structured.
Traceback (most recent call last):
  File "/usr/local/bin/psiturk", line 9, in <module>
    load_entry_point('PsiTurk==2.1.2', 'console_scripts', 'psiturk')()
  File "/Library/Python/2.7/site-packages/psiturk/command_line.py", line 14, in process
    launch_shell()
  File "/Library/Python/2.7/site-packages/psiturk/command_line.py", line 104, in launch_shell
    ps.run(cabinmode=args.cabinmode)
  File "/Library/Python/2.7/site-packages/psiturk/psiturk_shell.py", line 1787, in run
    shell.cmdloop()
  File "/Library/Python/2.7/site-packages/cmd2.py", line 1299, in cmdloop
    self._cmdloop()   
  File "/Library/Python/2.7/site-packages/cmd2.py", line 910, in _cmdloop
    self.preloop()
  File "/Library/Python/2.7/site-packages/psiturk/psiturk_shell.py", line 186, in preloop
    readline.read_history_file('.psiturk_history')
IOError: [Errno 22] Invalid argument

I have installed the gnureadline package, but it seems like for some reason psiturk is still getting the libedit version. Is this a bug?

@john-guerra
Copy link
Author

Changing line 21 of

/Library/Python/2.7/site-packages/psiturk/psiturk_shell.py

from

import readline

to

import gnureadline as readline

fixed the problem

@gureckis
Copy link
Member

Sorry, what are the differences between these two lines?

@john-guerra
Copy link
Author

Ups, my bad, I corrected my comment so people don't get confused

@ghost
Copy link

ghost commented Mar 12, 2015

Thanks for figuring this out.

kevinmickey added a commit to kevinmickey/psiTurk that referenced this issue Apr 9, 2015
@ghost
Copy link

ghost commented Jun 1, 2015

How did you modify the file? Even when I manage to edit the file (C-x C-q on emacs) I can't save it. How did you over write the permissions?

@john-guerra
Copy link
Author

You have to do it with the user root

$ sudo emacs filename

Should do the trick (If you have sudo permissions) or

$ su
(root password)
Then

emacs filename

John

On Mon, Jun 1, 2015, 1:55 PM laxminair notifications@github.com wrote:

How did you modify the file? Even when I manage to edit the file (C-x C-q
on emacs) I can't save it. How did you over write the permissions?


Reply to this email directly or view it on GitHub
#173 (comment).

@ayman
Copy link

ayman commented Jul 16, 2015

While this is a fair work around, it causes me an issue running python27 installed via MacPorts. Specifically, the prompt fails to print color codes correctly:

[[1mpsiTurk[0m server:[91moff[0m mode:[1msdbx[0m #HITs:0]$

Which seems to be related to cmd2.py where at line 906 we find:

            try:
                import readline
                self.old_completer = readline.get_completer()
                readline.set_completer(self.complete)
                readline.parse_and_bind(self.completekey+": complete")

if I edit the import here to read import gnureadline as readline then the color prompt renders correctly. However we've left the scope of psiturk to make an edit. I suppose the _cmdloop could be overridden in psiturk_shell.py.

@dbirman
Copy link

dbirman commented Jan 23, 2017

This problem still appears for some users by the way, appears to be an OS X specific problem, might be worth seeing whether the change can be merged at this point...

@deargle
Copy link
Collaborator

deargle commented Jan 24, 2017

Ha, I just helped a friend with this not two hours ago.

I don't have a mac, so can someone test this for me at line 21?

try:
    import gnureadline as readline
except ImportError:
    import readline

Edit: I'll test it on a system without gnureadline

deargle added a commit that referenced this issue Jan 24, 2017
importing gnureadline fixes broken things

see #173
@deargle
Copy link
Collaborator

deargle commented Jan 24, 2017

Who needs testing! Merged. Would be nice if some other PC and mac users could pull down @master and test against that before I create a tag, though.

Edit: fwiw I did test this on linux mint.

Edit 2: and sorry, no color fixes yet

@deargle
Copy link
Collaborator

deargle commented Jan 25, 2017

Made a minor release anyways (v2.1.7) because yolo.

@gureckis
Copy link
Member

👍, were you able to push it to pip?

@deargle
Copy link
Collaborator

deargle commented Jan 25, 2017

Yup, thanks to good old Travis CI.

@deargle deargle closed this as completed Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants