V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
gavingeng
V2EX  ›  MacBook Pro

切换到zsh后出现的一些问题,大家有遇到过吗

  •  
  •   gavingeng · 2012-09-20 11:10:03 +08:00 · 3354 次点击
    这是一个创建于 4207 天前的主题,其中的信息可能已经有所发展或是发生改变。
    1. 今天无意中写了个python脚本,其中有导入time包,但报错,之前一直都没有问题的,并且在bash下也没有问题
    >>python
    Python 2.7.2 (default, Jun 20 2012, 16:23:33)
    [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import time
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "time.py", line 10, in <module>
    print time.time()
    TypeError: 'module' object is not callable

    之后我又重新source $HOME/.profile,还是不行,不知原因出在哪里,bash下到没问题

    2.还有一个问题,现在想不起来了......
    5 条回复    1970-01-01 08:00:00 +08:00
    wwwjfy
        1
    wwwjfy  
       2012-09-20 11:24:52 +08:00   ❤️ 1
    基本看来是你的python脚本就是time.py,import的是当前目录下的time,不是系统的time,然后time.py里又import了系统的time,所以time.time就是系统的time,要不你试试time.time.time()
    gavingeng
        2
    gavingeng  
    OP
       2012-09-20 11:26:23 +08:00
    gavingeng
        3
    gavingeng  
    OP
       2012-09-20 11:30:11 +08:00
    @wwwjfy
    为何在bash下就没什么问题,反而在zsh下出现这个问题呢
    wwwjfy
        4
    wwwjfy  
       2012-09-20 12:08:56 +08:00
    @gavingeng 跟zsh应该没关系,最多也就是类似自动补全或切换路径之类的,要么是执行所在的路径不一样..
    bitsmix
        5
    bitsmix  
       2012-09-20 12:10:53 +08:00
    #python新手必犯错误#
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   960 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 21:16 · PVG 05:16 · LAX 14:16 · JFK 17:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.