终端开放时的Python怪异


2

当我打开终端时,我看到以下内容:

Last login: Wed Feb  8 18:30:05 on ttys029
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/handlers.py", line 75, in emit
    self.doRollover()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/handlers.py", line 132, in doRollover
    os.rename(self.baseFilename, dfn)
OSError: [Errno 2] No such file or directory
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 1472, in shutdown
    h.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 740, in flush
    self.stream.flush()
ValueError: I/O operation on closed file
Error in sys.exitfunc:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 1472, in shutdown
    h.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 740, in flush
    self.stream.flush()
ValueError: I/O operation on closed file

一切似乎都有效,但这很难看,可能会警告未来的麻烦。我在这台机器上安装了Python 2.7,然后将其删除为virtualenv以恢复2.6作为系统默认值。

有关如何调试此问题的任何想法?

编辑:

我的 .profile 打电话给 virtualenvwrapper.sh - 正如我所看到的那样,它位于下方 .../Versions/2.7 Python那么也许我应该在那里寻找问题?


也许我在这里遗漏了一些东西,但是当你启动Terminal.app时为什么python会加载任何东西?你的.bashrc或.profile中是否有特定的东西可以执行一些python代码?
cm2

是的,virtualenvwrapper.sh,看看我的编辑。
chernevik

是的,就是这样 - 指向/Versions/Current/bin/virtualenvwrapper.sh的.profile让这个残骸消失了。短语作为答案,我会选择它。
chernevik

看起来你自己回答了。可以接受你自己的答案。
cm2

Answers:


1

来自评论:

检查你的 .bashrc 要么 .profile 对于Python特定的代码 - 如果你发现某些东西,确保它指向正确的版本,不管它 .../Versions/Current/....../Versions/2.7/..., 管他呢。


问题是正确的,但解决方案不一定 - 如果您有多个蟒蛇,您当前的python可能不是您想要的那个
Mark

@Mark:这是怎么回事?
Ethan Furman
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.