尝试使用pyperclip的复制功能时出现错误代码

时间:2019-09-09 20:03:02

标签: clipboard pyperclip

我正在尝试创建一个非常简单的密码管理器程序,该程序将利用pyperclip将设置的密码复制到剪贴板中以便于访问。见下文:

#password.py - An insecure password manager program.
import pyperclip

def passwordManager():
    passwords = {"email": "password1234", "aws": "password4321", "macbook": "thisismypassword2019"}

    print("Type service needed:\n1. Email\n2. AWS\n3. Macbook")
    serviceSelected = raw_input().lower()
    if serviceSelected in passwords:
        pyperclip.copy(passwords[serviceSelected])
        print("Password for %s copied to clipboard!" % serviceSelected)
    else:
        print("There is no service accociated '%s'. Please try again." % serviceSelected)


passwordManager()

我早些时候运行程序很不错,但是突然我开始收到一个错误代码,看起来好像是从pyperclip方面来的。

Traceback (most recent call last):
  File "./password.py", line 17, in <module>
    passwordManager()
  File "./password.py", line 11, in passwordManager
    pyperclip.copy(passwords[serviceSelected])
  File "/Library/Python/2.7/site-packages/pyperclip/__init__.py", line 615, in lazy_load_stub_copy
    copy, paste = determine_clipboard()
  File "/Library/Python/2.7/site-packages/pyperclip/__init__.py", line 516, in determine_clipboard
    import Foundation  # check if pyobjc is installed
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/Foundation/__init__.py", line 8, in <module>
    import objc
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/__init__.py", line 28, in <module>
    from objc._bridgesupport import *
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 13, in <module>
    import pkg_resources
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 37, in <module>
    import email.parser
  File "/Users/harrisonglotz/Desktop/python/email.py", line 6, in <module>
    pyperclip.copy(text)
  File "/Library/Python/2.7/site-packages/pyperclip/__init__.py", line 615, in lazy_load_stub_copy
    copy, paste = determine_clipboard()
  File "/Library/Python/2.7/site-packages/pyperclip/__init__.py", line 517, in determine_clipboard
    import AppKit
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppKit/__init__.py", line 27, in <module>
    sys.modules['AppKit'] = mod = objc.ObjCLazyModule('AppKit',
AttributeError: 'module' object has no attribute 'ObjCLazyModule'

我尝试卸载和重新安装pyperclip以及pip。任何想法可能是什么原因造成的?非常感谢您!

0 个答案:

没有答案