MandelbrotPi
MandelbrotPi

Reputation: 1

pyperclip issues with PyCharm and batch files

I've been working through the book 'Automate the Boring Stuff With Python' and am doing the mclip chapter project, the code is fine, but I'm having issues with the execution.

the idea of the program is that it's a callable program from window's Run function, you should be able to type in run: mclip [keyphrase] which corresponds to a dictionary in the program that then copies to your computer's clipboard, a message that you can easily paste.

the issue arises that when I'm running the program through PyCharm, it runs fine, but I can't execute with a sys.args variable to fully run the program, and when I try and run it using windows run, and I include a sys.args variable keyphrase, the program returns an error saying I don't have the ability to import pyperclip when I have done that before already

I have edited the PATH variable of my machine to include everything python related in at least three different configurations, but I don't know why the windows run application cannot find pyperclip, as every time I go to install pyperclip with "pip install pyperclip" at all locations python could be, and all locations that are being referenced in PATH, I get a "you already have pyperclip installed" message

I don't know what to do, and there's not any questions that I've seen thus far that have been helpful.

#! python3
# mclip.py - A multi-clipboard program
import sys
import pyperclip

TEXT = {'agree': """Yes, I agree. That sounds fine to me.""",
        'busy': """Sorry, can we do this later this week or next 
week?""",
        'upsell': """would you consider making this a monthly 
donation?"""}

if len(sys.argv) < 2:
    print('Usage: python mclip.py [keyphrase] - copy phrase text')
    sys.exit()

keyphrase = sys.argv[1]  # first command line arg is the keyphrase

if keyphrase in TEXT:
    pyperclip.copy(TEXT[keyphrase])
    print('Text for ' + keyphrase + ' copied to clipboard.')
else:
    print('There is no text for ' + keyphrase)

Upvotes: 0

Views: 78

Answers (1)

MandelbrotPi
MandelbrotPi

Reputation: 1

Found out to import pyperclip or other libraries through PyCharm's terminal tab, this imports the library directly to the virtualenv that Pycharm is running as its interpreter

Upvotes: 0

Related Questions