使用Anaconda安装了Python,启动ipython时出现内核错误。

4

我安装了Anaconda版本的Python,并更改了路径,以允许在终端中使用Python命令。

然而,当我输入ipython时,会出现以下错误。

Traceback (most recent call last):
  File "/Users/mrbighit/anaconda/bin/ipython", line 6, in <module>
    sys.exit(start_ipython())
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 563, in launch_instance
    app.initialize(argv)
  File "<string>", line 2, in initialize
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 332, in initialize
    self.init_shell()
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 348, in init_shell
    ipython_dir=self.ipython_dir, user_ns=self.user_ns)
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/config/configurable.py", line 354, in instance
    inst = cls(*args, **kwargs)
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 328, in __init__
    **kwargs
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 465, in __init__
    self.init_history()
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1521, in init_history
    self.history_manager = HistoryManager(shell=self, parent=self)
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/core/history.py", line 498, in __init__
    self.new_session()
  File "<string>", line 2, in new_session
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/core/history.py", line 68, in needs_sqlite
    return f(self, *a, **kw)
  File "/Users/mrbighit/anaconda/lib/python2.7/site-packages/IPython/core/history.py", line 516, in new_session
    NULL, "") """, (datetime.datetime.now(),))
OperationalError: attempt to write a readonly database

打开ipython qtconsole时也会出现内核错误。我已经确保我拥有正确的conda列表包。

只是为了检查,sudo ipython 能够工作吗? - Padraic Cunningham
我相信你是使用sudo命令将Anaconda安装到了你的主目录下,这就是为什么你会遇到这些问题。你可以安全地删除/Users/mrbighit/anaconda目录,并以普通用户身份安装Anaconda。 - Burhan Khalid
我使用bash命令安装了Anaconda,没有指定安装目录,只是按照网站的说明进行操作。我没有使用sudo安装。我应该进行图形化安装并将其安装到不同的目录中吗? - hamm44
2个回答

2
在您的系统上查找一个名为.config/ipython/history.sqlite的文件,并使用以下命令更改所有权:sudo chown ...,因为该文件被root拥有,所以您看到了这个错误。

请问您能否详细说明如何在终端命令中更改所有权?我对Mac系统非常陌生。 - hamm44
你找到了 history.sqlite 文件吗?它也可能在 .ipython/profile_default 这样的地方。 - Padraic Cunningham
我使用了“find /Users/mrbighit -name "history.sqlite"”命令,然后使用了“sudo chown -v”命令,它起作用了。 - hamm44
是的,“find”非常方便,我想知道它最初是如何出现的? - Padraic Cunningham

0

打开一个普通的Python REPL,运行:

from IPython.utils.path import locate_profile
locate_profile('default')

检查您是否对该文件夹具有写入权限


/Users/mrbighit/.ipython/profile_default 是位置,我能看到该文件夹具有写入权限。我尝试了sudo ipython,ipython可以载入且没有问题,但只使用ipython时却出现了错误信息。 - hamm44

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接