我的 Anaconda Python 安装似乎有问题。
当我通过 cmd 运行 Python 时,它可以工作,并且我也可以直接通过 cmd 运行 Python 程序,甚至导入 scipy、numpy、matplotlib 等。
但是,当我尝试使用 cmd 命令“ipython”运行 IPython 时,出现错误:
Traceback (most recent call last):
File "C:\Users\User\Anaconda\Scripts\ipython-script.py", line 5, in <module>
sys.exit(start_ipython())
File "C:\Users\User\Anaconda\lib\site-packages\IPython\__init__.py", line 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "C:\Users\User\Anaconda\lib\site-packages\IPython\config\application.py", line 563, in launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "C:\Users\User\Anaconda\lib\site-packages\IPython\config\application.py", line 92, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\User\Anaconda\lib\site-packages\IPython\terminal\ipapp.py", line 332, in initialize
self.init_shell()
File "C:\Users\User\Anaconda\lib\site-packages\IPython\terminal\ipapp.py", line 348, in init_shell
ipython_dir=self.ipython_dir, user_ns=self.user_ns)
File "C:\Users\User\Anaconda\lib\site-packages\IPython\config\configurable.py", line 354, in instance
inst = cls(*args, **kwargs)
File "C:\Users\User\Anaconda\lib\site-packages\IPython\terminal\interactiveshell.py", line 328, in __init__
**kwargs
File "C:\Users\User\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 465, in __init__
self.init_history()
File "C:\Users\User\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 1521, in init_history
self.history_manager = HistoryManager(shell=self, parent=self)
File "C:\Users\User\Anaconda\lib\site-packages\IPython\core\history.py", line 498, in __init__
self.new_session()
File "<string>", line 2, in new_session
File "C:\Users\User\Anaconda\lib\site-packages\IPython\core\history.py", line 68, in needs_sqlite
return f(self, *a, **kw)
File "C:\Users\User\Anaconda\lib\site-packages\IPython\core\history.py", line 516, in new_session
NULL, "") """, (datetime.datetime.now(),))
DatabaseError: database disk image is malformed
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
c.Application.verbose_crash=True
我认为错误是由于DatabaseError: database disk image is malformed
错误引起的,但不确定这意味着什么。
有什么建议吗?
答案1
问题在于 SQLite 数据库损坏。在本例中是history.sqlite
数据库。
请查看您的配置文件文件夹(或您在配置中设置的路径)是否可以找到文件history.sqlite
。
如果您可以找到它,请先进行备份(以防万一您需要它),然后创建一个同名的新空文件(history.sqlite)。
现在尝试再次运行 IPython,您应该能够启动它。