-
Notifications
You must be signed in to change notification settings - Fork 226
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
Extra space with tab completion in ipython #42
Comments
Here is a work around if anyone is interested. Works on Linux, untested on other systems. Download the readline library source code from http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html. Unpack the tarball, edit lines 340 and 471 (these might change for later version, this is for 6.2)
to
build the source with shared libraries
Now copy Now IPython (and other anaconda programs) will no longer will add a space after a tab completion. This works for me, but use at your own risk, I am not responsible if it brakes anything! |
So apparently the real fix is to update the Anaconda readline to 6.2.1. |
Just updating to readline 6.2.1 will still insert the space. You need to make the change to the |
Is this change a good idea to apply for everyone? Should we patch the readline we build in Anaconda to have it? |
I don't know if this should be pushed out to everyone. The problem seems to be present only on the Linux version of Anaconda. A default install on my Mac did not produce the extra space after a tab completion, I haven't checked the Windows version. The above works for me, but should probably be tested and checked a bit better before pushing out to everyone. |
This bug drives me nuts! Nobody's using Linux at continuum? I first made sure that no libreadline.so library could get in the way (removing all of them indicates that the readline functionality is not present in ipython, which tells us with very high probability that this lib is not statically linked) and then copied the patched libs to anaconda/lib. The annoying space is still appended, so it looks like the variable rl_completion_append_character is set by the library caller... |
I'm not sure if the append character is the issue. The append character is also |
Also, this is not IPython specific. I can reproduce the same thing by using a PYTHONSTARTUP with import readline, rlcompleter
readline.parse_and_bind("tab: complete") in the regular Python interpreter. |
1.9 is out an no fix in sight. I guess, Linux isn't just that imporant. Python version of Please, just compile
Even better way:
|
The readline recipe in the conda-recipes repo has this change, but for me, it doesn't fix the problem. My test is, in IPython, |
@asmeurer please make sure, that the referred recepy indeed overwrites all instances of In my case, EDIT: to check the path, your
|
Oh, you're right. The readline being loaded is part of the python package, not the readline package. |
Oh but that doesn't make sense. The readline in Python has the right append character. |
I am not sure which
|
(with the patched readline installed)
|
The patch in the recepy is not complete. It should also change the second occurence of
|
OK, I built it with that patch, and it seems to fix it. You can get it with |
the patch does not work for me. I have the latest conda version, but not the latest anaconda. |
I am having this same problem on 64bit unix |
The problem has nothing to do with the GNU readline library, but rather with an erroneous build of the Python interpreter (or more specifically the Python readline module). Just to make it clear (because there seemed to be some confusion in the previous postings between GNU readline library and the Python readline module), the file The problem with the Anaconda Python package is visible inside the pyconfig.h file that comes with Anaconda, where the So if the Python interpreter that comes with Anaconda is built correctly, there is no need to add another "remove-trailing-spaces" patch to libreadline or to install gnureadline from PyPI. I would have tried to fix the build problem directly, but unfortunately the "recipe" for the Python package that comes with Anaconda does not seem to be publicly available. On the linux machines where I have installed Anaconda (running CentOS 6.5 and Fedora 20) the problem could be easily fixed by compiling Python from sources (linking against the system version of libreadline), replacing the After that I installed the Anaconda readline package again (
which failed to build the
The reason for this was, that the readline extension module is built by a Python Now the
while the
and thus needs to be linked together with So because the build script picks the wrong library, it comes to the conclusion that it does not need to link any other library, which then results in missing symbols when importing the module. Luckily this behaviour can be easily fixed by making sure that the library search order is correct (first look into directories specified by
After this modification the build went through without errors and the After making the file relocatable with
I successfully used it to replace the broken Anaconda readline modules on different installations (Fedora, Ubuntu 12.04, Arch Linux). On Arch Linux I had a little problem, because the
I think this tinfo/ncurses problem would not appear in an official Anaconda build, because I think I read somewhere that Anaconda is built using CentOS 5, where ncurses is also not split into two libraries. So the So I think all that needs to be done to get finally rid of this annoying trailing-space bug is to fix the Anaconda Python package by making sure that autoconf script finds (and uses) the Anaconda version of the GNU readline library and to make sure that the Also, I think it would maybe be a good idea to include the ncurses library into the Anaconda distribution. This would make it possible to link |
Thanks for the write up. We'll look into fixing this. Couldn't you have used |
The `--prefix`` option can be used to specify the installation directory - not the location of additional header and library files. The |
Sorry, we never figured out how to get around the issues that arose when compiling ncurses (conda-archive/conda-recipes#112 (comment)). If you know how to fix it, let us know. If you can provide a working recipe for |
Strange... @timothydmorton's posting, you just replied to, doesn't seem to exist anymore. Anyway, I still think that something went wrong during the build of the Python readline extension module. Have you checked, that the |
I agree with kbg. Furthermore, the extra tabs are not the only problem with the anaconda readline package. Compiling R using the anaconda/include folder as the C_INCLUDE_PATH and anaconda/lib folder as the LIBRARY_PATH does not work on Ubuntu because of a problem with the anaconda readline library. Running ./configure in the R source directory leads to the following error: Oddly enough, R compiles just fine using the anaconda readline library on CentOS... |
I tried to make a simplified instructional gist for scenarios like mine: https://gist.github.com/benjaminmgross/0fffd01f9037aaa76a9e |
I'm having this problem with Anaconda 2.1.0 and stock Debian 7. Any better solutions? |
I've read over this thread at least a couple times, and I not sure if anyone found a solution or even a reliable workaround. Could someone who understands the issue well please provide a summary of what's causing it? For my benefit, and the benefit of anyone else who reads this in the future. Is it the readline package? Is it the built-in python module? Is it ncurses? Is it the way Continuum compiles readline, prior to compiling Python? We've been using a custom-built Python 2.7 distribution that I created on our CentOS 6 machines, and I haven't seen this problem there; or in the Python packages installed on Fedora. Installing ipython with pip in a virtualenv doesn't have this issue either. So I'm a little confused about what makes the anaconda version different. I was hoping to migrate our systems to use anaconda, so I don't have to keep maintaining my custom distribution. I've tried Canopy, but found it to be too buggy to justify paying the $200 licensing fee. Are these kinds of issues typical with Anaconda, or is it normally quite stable? |
Ok. I'm going to give it a try. First this, from @kbg: "The problem with the Anaconda Python package is visible inside the pyconfig.h file that comes with Anaconda, where the HAVE_LIBREADLINE and all the HAVE_RL_* entries are not defined. Apparently the Python readline module was built anyway, but without all the code inside the HAVE_RL_* ifdefs, which already handles the trailing spaces." So the python readline module is compiled with a bad pyconfig.h. Why is it that way? What I don't understand is why there were problems compiling Python 2.7.6 against the system readline library. I was able to compile 2.7.6 on CentOS 6, and readline.so was created without problems. I used:
Is it because you were using the anaconda library path? Is it a conflict between a library in that path, and the system libreadline? So then what's needed, If understand correctly, is for Continuum to fix the bad pyconfig.h, and package ncurses with Anaconda to satisfy the readline.so dependency. Correct? |
There is a conflict between system ncurses & anaconda one: common linux distros build separate ncurses & libtinfo libs (with a special ncurses build flag) while conda ships a single ncurses binary. Python build script detects system-wide libtinfo.so and makes readline.so dependent on it, but since the library is not installed in the env, it is not found and this breaks readline.so There are two fixes: the better one, from @kbg, patches python build script so that ncurses/tinfo autodetection runs on conda-supplied library, and mine, which mitigates the issue patching ncurses build script to build separate libtinfo library so that it is installed into the env and resolved properly. Alas, Continuum guys seem to |
@orodbhen , addressing your other question
Conda employs some non-100%-reliable techniques, like patching strings that look like paths in the binaries. Most of the packages are thoroughly tested, so they are quite stable as long as you don't do something unusual. At least they worked quite well for me. However, there are some corner cases. For example I have run into a case when such binary patching corrupted the debug info and made valgrind choke. Another issue I have run into is that conda-shipped qt library is built without ssl support (#140). Even though I'd love to help, it is far from trivial to find out what prevents qt from using openssl package without seeing the qt recipe, and I'm not sure if the publicly available recipe is compatible with the one Continuum uses for building packages in the official channel. |
Thanks @immerrr . It makes a lot more sense now. I have a Qt 4 build in my custom Python install with SSL enabled, that works quite well. But I'm not very familiar with the conda build system. I was actually in the process of creating a tool for managing python packages and virtual envs, as well as non-python packages. I was looking at making a python clone of homebrew for Linux, with some changes. But then I discovered that conda does all of the above. Even if Continuum's packages prove unreliable, it at least provides a management framework that may work for us. I had a heck of a time getting Python to build 32 bit on a 64 bit system. It's build scripts don't do a great job at honoring CFLAGS and LDFLAGS. Anyways, I'll try the patch and see if it solves the problem for me. Why does "conda search ncurses" not return any results? |
The patch from @kbg fixed the issue for me. It also fixed a segfault I was getting with a Traitsui script, when trying to run it in the Anaconda env. I wonder what other differences there are in Continuum's build recipe for Python. |
How do I keep conda from downgrading Python to the original version every time I install something? Do I have to give the patched Python the same version number as the original? |
I'll try to review and merge the mentioned patch this week |
Ok, so I went through the entire thread trying to understand its main points. I have one question for @kbg: The configure step in your Python recipe is ./configure --prefix=$PREFIX \
--enable-shared --enable-ipv6 --enable-unicode=ucs4 \
--with-tcltk-includes="-I$PREFIX/include" \
--with-tcltk-libs="-L$PREFIX/lib -ltcl8.5 -ltk8.5" \
CPPFLAGS="-I$PREFIX/include" \
LDFLAGS="-L$PREFIX/lib -Wl,-rpath=$PREFIX/lib,--no-as-needed" How important are the |
Just as a side note to @immerrr: the error you mentioned about Qt is solved now, as almost all other important issues related to it :-) |
I tested @kbg suggestion and everything seems to be working as expected!! I submitted a PR to our internal repo, so let's hope this is fixed soon :-) |
@ccordoba12 that is so awesome, thank you! |
Ok guys, we just released a new version of Python 2 (specifically Sorry for the big delay in addressing this issue, and thanks a lot to @kbg for providing a very informed and clear solution. Happy coding!! :-) |
@ccordoba12, will python3 be updated soon too? |
Thanks for fixing this! I can verify the new build, 2.7.9-3, no longer inserts an extra tab. |
@immerrr, I thought Python 3 doesn't have this problem. I'll verify and report back :-) |
Ok, I tested it in Python 3 and @immerrr is right, the extra space is a problem there too. We'll try to release a new package soon to fix this problem :-) |
The extra space issue seems to have been fixed in Python 3 with the release of python 3.4.3-1 and python 3.3.5-4. Thanks! |
@jjhelmus, thanks for testing!! So this infamous bug can finally be closed , yay!! \o/ |
This issue still persists.
see details: https://groups.google.com/a/continuum.io/d/topic/anaconda/oRV1Yc-H3IY/discussion
The text was updated successfully, but these errors were encountered: