OsX Python 3.5错误的解释器:没有这样的文件或目录 [英] OsX Python 3.5 Bad Interpreter: no such file or directory

查看:95
本文介绍了OsX Python 3.5错误的解释器:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从终端窗口运行以下代码.我正在遵循在该网站 https://automatetheboringstuff.com/chapter6/上找到的教程.我的文件名为"pw.py",我运行chmod + x pw.py以使其可从终端窗口执行.但是,当我运行./pw.py时,出现一个错误,提示"-bash:./pw.py:python:错误的解释器:没有这样的文件或目录".知道我错过了什么吗?感谢您的帮助!

I am trying to run the following code from the terminal window. I am following the tutorial found on this website https://automatetheboringstuff.com/chapter6/ . The name of my file is "pw.py" I ran chmod +x pw.py to make it executable from the terminal window. However, when I run ./pw.py I get an error saying "-bash: ./pw.py: python: bad interpreter: No such file or directory". Any Idea what I missed? Thanks for the help!

#! /usr/bin/python
# pw.py - An insecure password locker program.

PASSWORDS = {'email' : 'F7minlBDDuvMJuxESSKHFhTxFtjVB6' ,
             'blog' : 'VmALvQyKAxiVH5G8v01if1MLZF3sdt' ,
             'luggage' : '12345'}
import sys, pyperclip
if len(sys.argv) < 2:
    print('Usage: python pw.py[account] - copy account password')
    sys.exit()

account = sys.argv[1]    # first cammand line arg is the account name

if account in PASSWORDS:
    pyperclip.copy(PASSWORDS[account])
    print('Password for ' + account + ' copied to clipboard.')
else:
    print('There is no account named ' + account)

推荐答案

我发现了我的问题.我没有在终端中正确执行它.当我需要输入"python pw.py"以使其运行脚本时,我正在输入"./pw.py".感谢您的帮助.

I figured out my problem. I was not executing it in the terminal correctly. I was entering './pw.py' when I needed to enter 'python pw.py' in order for it to run the script. Thanks for the help.

这篇关于OsX Python 3.5错误的解释器:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆