WARNING: IPython History requires SQLite, your history will not be saved

前端 未结 5 1246
小蘑菇
小蘑菇 2021-01-31 20:54

Hi I\'m using Ubuntu release 12.10 (quantal) 32-bit with Linux Kernel 3.5.0-21-generic. I\'m trying to get IPython\'s History to work. I\'ve set it up using pythonbrew and a vir

相关标签:
5条回答
  • 2021-01-31 21:34

    This warning appears on macOS when python is installed with pyenv. By default it installs python without sqlite. These commands reinstall python with sqlite support:

    pyenv uninstall 3.7
    CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.7
    
    0 讨论(0)
  • 2021-01-31 21:37

    What worked for me (using osx + homebrew + brewed python):

    # Reinstall Python 2.7 with sqlite
    brew remove python
    brew install readline sqlite gdbm --universal
    brew install python --universal --framework
    
    # Reinstall iPython with correct bindings
    pip uninstall ipython    
    pip install ipython
    

    And you should be good to go.

    0 讨论(0)
  • 2021-01-31 21:41

    I've also read in a few places that I may have to rebuild Python.

    This is correct. SQLite is part of the standard library, and is built when you compile Python. There are a few 'optional' parts of the standard library, which Python will simply skip (with minimal warning, unfortunately) if the dependencies are missing at build time, and sqlite is one of these. You should be able to just install libsqlite3-dev, then rebuild Python and you should be set. Keep an eye on the build messages, as they do report which modules they are skipping due to missing dependencies.

    0 讨论(0)
  • 2021-01-31 21:52

    Thanks to minrk for pointing me in the right direction. All I had to do was rebuild python. I've outlined the steps below for those that are using pythonbrew. Notice that I already installed the libsqlite3-dev package up in the question section.

    First, with the proper version of python and virtual environment loaded up run the command:

    $ pip freeze -l > requirements.txt
    

    This gives us a text file list of all of the pip packages that have been installed in the virtual environment for this particular python release in pythonbrew. Then we remove the version of python from pythonbrew and reinstall it (this is the "rebuild python" step):

    $ pythonbrew uninstall 2.7.3
    $ pythonbrew install 2.7.3
    

    After that, we switch over to the newly installed python version 2.7.3 and create a new virtual environment (which I've called "sci"):

    $ pythonbrew switch 2.7.3
    $ pythonbrew venv create sci
    $ pythonbrew venv use sci
    

    Ideally you should be able to run the command:

    $ pip install -r requirements.txt
    

    and according to this pip should reinstall all the modules that you had in the virtual environment before we clobbered that version of python (2.7.3). It didn't work for me for whatever reason so I manually installed all of the modules using pip individuality.

    $ ipython --pylab
    
    Python 2.7.3 (default, Jan  5 2013, 18:48:27) 
    Type "copyright", "credits" or "license" for more information.
    
    IPython 0.13.1 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
    

    and IPython history works!

    0 讨论(0)
  • 2021-01-31 21:53

    You should rebuild your python with sqlite support

    sudo apt-get install libsqlite3-dev
    wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
    tar -xvf Python-2.7.15.tgz
    cd Python-2.7.15
    ./configure
    make
    sudo make install
    

    Recreate your virtual environment and you should be good to go

    rmvirtualenv venv
    mkvirtualenv -p python2 venv
    workon venv
    pip install -r requirements.txt
    # or
    pip install ipython
    
    0 讨论(0)
提交回复
热议问题