|

Python and Windows – Part 2

A couple of posts ago, I wrote about learning how to run Python outside of the Python software environment which I think is called the IDE. You could also use the Notepad to create Python programs but the IDE environment makes it so much easier to run, test, and see results. I’m using Anaconda’s Jupyter which is saved as ipynb extension rather than py extension. So, I had to learn how to get a program with a py extension before I could run it in the Windows environment. Next, I needed to figure out what was required for running Python programs in Windows rather than in Jupyter, hence I went through some exercise of checking where my PATH was, checking where my Python executables were, checking if my Python interpreter was in the PATH environment, and then creating the batch file for running the Python program and figuring out where to save it before I could even call it up in Windows.

Whew!

This week I learned a little bit about installing 3rd party modules to use in my own Python programs (from Automate the Boring Stuff by Al Sweigart). Rather than I creating all of the programs to do basic stuff, I can use other modules (so long as it’s free) to shortcut the work. The first one I encountered in the book was copying from and pasting to the clipboard: pyperclip. You use “pip” to install 3rd party modules and if you install Python for a Windows machine, “pip” should have installed along with Python.

The question is: where did the “pip” folder go? You might have to move the “pip” folder from wherever the installation saved to your PATH environment. I think I did a search and found the “pip” folder in C:\Users\veron\AppData\Local\ (or maybe I moved it there – I don’t remember). You can test if the “pip” folder is in the right spot by doing “pip install –user MODULE” where MODULE is the name of the module you want to install (for instance: pyperclip). If “pip” is in not in the PATH environment, you’ll get some kind of error message.

If “pip” is in one of the PATH environments, then the module will install – in my case “pyperclip”. I think I then went ahead and moved the “pyperclip” folder to C:\Users\veron\ after installation – my Python programs worked with the folder in there.

This week I have created some small programs using the “pyperclip” and created a batch file to run the Python program containing the “pyperclip” module from Windows via WIN-R. I’ve done a few variations of batch programming to solidify my understanding of what to do if I want to run a Python program from Windows.

Before I get into learning cool programs to create, which I’m keen to do – the whole point of getting the book, I have two programs that I have to create.

And then it’s off to the fun (I hope) stuff.

(Yes, this is a very short post; I’m still working on my productivity.)

Similar Posts