1

I've tried googling around but haven't found much / anything, the following also doesn't help at all...

https://ipython.org/ipython-doc/3/interactive/magics.html

typical usecase is:

In [31]: from sqlalch<TAB>  
Caching the list of root modules, please wait!
(This will only be done once - type '%rehashx' to reset cache!)

em
Caching the list of root modules, please wait!
(This will only be done once - type '%rehashx' to reset cache!)


Caching the list of root modules, please wait!
(This will only be done once - type '%rehashx' to reset cache!)


                        sqlalchemy 

Also running %rehashx by itself also doesn't help. I also pip installed pyreadline.

Any ideas what is going wrong? Where does %rehashx store info?

EDIT

The output from get_ipython().db['rootmodules_cache'] gives the following:

for key in d.keys(): print key
# /usr/local/bin
# /usr/lib/python3/dist-packages
# /usr/lib/python3.5
# /usr/local/lib/python3.5/dist-packages <- should be in here
# /usr/lib/python3.5/lib-dynload
# /usr/lib/python35.zip
# /usr/local/lib/python3.5/dist-packages/IPython/extensions
# /usr/lib/python3.5/plat-x86_64-linux-gnu
# /home/user/.ipython

import sqlalchemy
sqlalchemy.__file__
# /user/local/lib/python3.5/dist-packages/sqlalchemy/__init__.py

However sqlalchemy is not in the list

d = get_ipython().db['rootmodules_cache']
'sqlalchemy' in d['/user/local/lib/python3.5/dist-packages']
# False
evan54
  • 3,585
  • 5
  • 34
  • 61
  • This suggests that the cache isn't working correctly. What do you get from `get_ipython().db['rootmodules_cache']`? – Thomas K Oct 06 '16 at 16:45
  • @ThomasK I edited the question, any insights from the updated question? – evan54 Oct 07 '16 at 00:24
  • I think that suggests that that entry was already cached before you installed sqlalchemy. I don't think that should cause the 'Caching the list...' messages you see, though. Assuming you're using IPython 5, I bet this is something to do with prompt_toolkit doing completions in threads. Maybe it can be running that piece of code multiple times at once. Try running `%rehashx` , and then starting `import sqla` and let it sit for ~2 minutes without typing anything else - maybe it will manage to cache things successfully then. – Thomas K Oct 07 '16 at 10:41
  • ok this worked - so far - no idea why. However `get_ipython().db['rootmodules_cache']` gives an error now – evan54 Oct 08 '16 at 00:45
  • I just deleted the `.ipython/profile_default/db` folder and it created a new one and it seems to be working and is much faster... If it doesn't create problems in the future I'll probably just write that up as an answer... – evan54 Oct 08 '16 at 00:51
  • Hmm, strange. I'm glad you got it working. Refactoring the completion machinery is in the plans for IPython 6. – Thomas K Oct 08 '16 at 17:17

1 Answers1

0

This command solved to me, in the Ipython:

!rm .ipython/profile_default/db/*

I hope it adds to yours.