asweigart / pyperclip

Python module for cross-platform clipboard functions.
https://pypi.python.org/pypi/pyperclip
BSD 3-Clause "New" or "Revised" License
1.6k stars 193 forks source link

Pyperclip module not found but installed #226

Closed max-molden closed 2 years ago

max-molden commented 2 years ago

I have a program I wrote a couple of months ago using the pyperclip module to copy a generated password to my clipboard. I last used the program about a week ago and have made no changes to it or its use of pyperclip in well over a month.

When I went to run my program today it gives the following error:

Traceback (most recent call last): File "C:\Users\Max Molden\Desktop\Programming Work\Python\Password-Generator\password-gen.py", line 4, in import pyperclip as pc ModuleNotFoundError: No module named 'pyperclip'

When I run 'python --version' I get:

Python 3.10.5

When I run 'pip install pyperclip' I get:

Requirement already satisfied: pyperclip in c:\users\max molden\appdata\local\programs\python\python310\lib\site-packages (1.8.2)

When I run 'pip show pyperclip' I get:

Name: pyperclip Version: 1.8.2 Summary: A cross-platform clipboard module for Python. (Only handles plain text for now.) Home-page: https://github.com/asweigart/pyperclip Author: Al Sweigart Author-email: al@inventwithpython.com License: BSD Location: c:\users\max molden\appdata\local\programs\python\python310\lib\site-packages Requires: Required-by:

I am unsure as to what stopped working but any help would be greatly appreciated. Unless absolutely necessary, I would prefer not to show my entire program for multiple reasons. First, the error is happening (so far) only on the import line. Second, this is a program I wrote to generate passwords for myself, while not entirely of my own design, it still involves a layer of security to protect myself :)

I am using VS Code and using a bash terminal through GitBash within VS Code. If you would like any more information about my environment to help me I will gladly provide it.

max-molden commented 2 years ago

SOLVED: Today I set up my dev environment for C/C++ development for the first time on this machine and needed to install MinGW. In order for MinGW to work I needed to add it to path and I used the VS Code suggested MYSYS2 install for MinGW which included a python.exe file (not sure if other distributions of MinGW include this file). When I typed 'where python' into my terminal (which python on Linux) the .exe for MYSYS2 came up first. I simply needed to add the python.exe to the system PATH above the MinGW in the PATH (instead of only having python in the user system variables). This can be avoided, also, with virtual environments.

hugovk commented 2 years ago

Tip: https://snarky.ca/why-you-should-use-python-m-pip/