Python 终端显示“;ImportError:没有名为pyperclip的模块;
我正在编写一段代码,用户将在终端上运行python程序(我使用的是OSX),程序将用户名的密码复制到剪贴板 代码如下:Python 终端显示“;ImportError:没有名为pyperclip的模块;,python,macos,python-3.x,terminal,python-3.6,Python,Macos,Python 3.x,Terminal,Python 3.6,我正在编写一段代码,用户将在终端上运行python程序(我使用的是OSX),程序将用户名的密码复制到剪贴板 代码如下: import sys import pyperclip passwords={'AaruDon':'zxcvbnasdjl@!#@!#4324(3’,’Sandy’:’qjljeqkjleq’} # AaruDon and Sandy are usernames that the user might input in the Terminal idd=sys.argv[1
import sys
import pyperclip
passwords={'AaruDon':'zxcvbnasdjl@!#@!#4324(3’,’Sandy’:’qjljeqkjleq’} # AaruDon and Sandy are usernames that the user might input in the Terminal
idd=sys.argv[1] # idd would be the username that the user will put in the terminal while he is opening the program
if str(sys.argv[1])in passwords.keys():
pyperclip.copy(str(passwords[idd]))
print(' The password has been copied to the clipboard')
else:
print('Sorry. There is no such username.')
当我运行此程序时,我得到:
ImportError:没有名为pyperclip的模块
相信我,我以前在一些较旧的程序中导入了pyperclip,它确实起了作用!我不知道如果我试着从终端运行它为什么会抛出这个错误
我怎样才能摆脱这个
注意:Pyperclip已安装。我以前也检查过
编辑1)我在终端上运行了另一个程序,该程序也使用了pyperclip,它确实起了作用!问题仅在于此程序请参见此处:
我也有同样的问题。下载它并将其放入与脚本相同的目录中
@DavidG它已经安装完毕,请尝试安装pyperclip,然后查看您收到的信息,然后,您应该检查是否安装了不同版本的python,以及运行此脚本时使用的是哪一个版本,如果此版本作为对
pyperclip
@Dadep的访问,那么它已经安装了。您是否检查了它在PYTHONPATH
中?也许您已经为一个版本的python安装了它,但是,当从终端运行时,您使用的是未安装的其他版本。