我有一个简单的脚本,我试图从Windows运行:
脚本:
#! python3
# pw.py - An insecure password locker program
import sys
import pyperclip
PASSWORDS = {"email": "DHUSADIUSAHDDSAJO",
"blog": "fdsifjdsfjisdojfios",
"luggage": "fdsjifidsfhjifhui"}
if len(sys.argv) < 2:
print("Usage: python pw.py[account] - copy account password")
sys.exit()
account = sys.argv[1] # first command line arg is account name
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print("The password for your {} account has been sent to the computer \
clipboard.".format(account))
else:
print("There is no account named {}.".format(account))
批处理文件:
@py.exe C:\Users\Dave\Desktop\2016Coding\AutomateBoring\pw.py
@pause
我可以通过Idle和命令行运行此脚本而不会出现问题。但通过窗口,我收到:
<absolute filepath>, line 5, in <module>
import pyperclip
ImportError: No module named 'pyperclip'
我使用的是python 3.1.1,并且该模块最初安装在其默认的python27 / lib / site-packages中。在弄清楚之后,我使用pip-install --target
将其添加到&#39; python31&#39;的相同文件夹中。批处理和.py文件位于同一文件夹中,文件夹位置位于ev Path。