V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
vicence
V2EX  ›  Python

.py文件无法直接执行

  •  
  •   vicence · 2013-09-08 22:35:22 +08:00 · 3683 次点击
    这是一个创建于 3887 天前的主题,其中的信息可能已经有所发展或是发生改变。


    权限也加了,就是无法执行
    10 条回复    1970-01-01 08:00:00 +08:00
    ipconfiger
        1
    ipconfiger  
       2013-09-08 22:40:04 +08:00
    whereis python 看看你的解释器地址是不是 /usr/bin/python
    lennyh
        2
    lennyh  
       2013-09-08 22:42:41 +08:00
    shbang line有问题,貌似是文件格式的原因,试试dos2unix...
    hadoop
        3
    hadoop  
       2013-09-08 22:43:19 +08:00
    输入命令 which python 看看你的python的路径是哪个
    vicence
        4
    vicence  
    OP
       2013-09-08 22:54:18 +08:00
    @hadoop
    @ipconfiger

    都没问题
    skydiver
        5
    skydiver  
       2013-09-08 22:57:33 +08:00
    @vicence 脚本第一行写的什么?
    vicence
        6
    vicence  
    OP
       2013-09-08 23:05:30 +08:00
    @skydiver
    @ipconfiger
    @lennyh
    @hadoop
    是文件格式问题,谢谢你们
    013231
        7
    013231  
       2013-09-08 23:07:11 +08:00
    換行符的問題, 注意那個^M.
    Mutoo
        8
    Mutoo  
       2013-09-08 23:44:32 +08:00
    看到状态栏 a.py[+][python,,dos]
    果断 :set ff=unix
    vicence
        9
    vicence  
    OP
       2013-09-09 00:16:05 +08:00
    在window下,无论是dos,还是unix,都没问题,在太坑爹了
    TankyWoo
        10
    TankyWoo  
       2013-09-09 17:15:05 +08:00
    EOL的问题, 以前我也遇到过, 记录了下:

    http://www.wutianqi.com/?p=3392
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2297 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:41 · PVG 23:41 · LAX 08:41 · JFK 11:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.