Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Python "Automate the Boring Stuff" wants me to change Windows environment variables?
#1
So, I'm working through "Automate the Boring Stuff" for Python, and I to continue, it wants me to go to my Windows "Edit environment variables for your account" so that I can apparently run finished programs. However, I am in an office environment, and apparently they don't want me changing Windows system variable files. I completely think this is reasonable on my employer's part - and frankly I'm stumped as to why the book assumes that everyone will be able (and have permissions) to do this.

Basically, I need a work-around for continuing with Python that does not require me changing files inside Windows. Any help with this? I don't care if I have to put long strings into the command line. Can I get around this very odd "necessity" within this book? Or am I just out of luck and need to forget about Python?
Thanks for any help.
Quote
#2
Modifying the environment variables is not necessary, it's only done for convenience.
I'm assuming the book wants you to modify the path variable. If so, simply use the full path whenever you need to run a program (such as python or pip)
Quote
#3
You are exactly right - the path variable.
I'm so glad to hear that I can continue without changing this.
Thanks so much for the fast reply!
Quote
#4
There are two types of Environmental Variables- User and System.  Will they allow you to change the "User" level?

Basically, it is just a "hint" to the Windows OS on where to find "python.exe", and a few more Python related modules. Thus the suggestion that you add "C:\main_python_location \" and "C:\main_python_location \ Scripts" to the variables. Without it, you will manually have to include the path when invoking a file. Not a game changer, but does require a little extra typing.  Say your Python installation is located in "C\Python35\", with the variables, you simply type "python" into the command terminal, no matter where your are in the directory tree, and you will start the interactive shell. Without the variables. you would have to type "c:\python35\python" or change directory to "C:\Python35" then type "python". The environmental variables are Windows equivalent of the *nix PATH.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Quote
#5
If you change the PATH variable in the command prompt I think it's changed until system reboot. Let one who use Windows tell if I am wrong. Even if it's permanent you just add something to the PATH, so all the rest will work as usual.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#6
You can edit your environment only for the time being inside a command prompt, so that all edits will be undone when you close the box. This should work on your non-personal computer as well.

For example, create a new text file called "python_path.bat" and put these contents inside:

set "path=%path%;C:\main_python_location\;C:\main_python_location\scripts" 
cd "c:\my_python_files\"
cmd
You can now start the file and work with the command prompt and enlarged path variable
sparkz_alot likes this post
Quote
#7
(Dec-13-2016, 09:43 AM)Kebap Wrote: You can edit your environment only for the time being inside a command prompt, so that all edits will be undone when you close the box. This should work on your non-personal computer as well.

For example, create a new text file called "python_path.bat" and put these contents inside:

set "path=%path%;C:\main_python_location\;C:\main_python_location\scripts" 
cd "c:\my_python_files\"
cmd
You can now start the file and work with the command prompt and enlarged path variable

You should be able to run this with Windows Task Scheduler for every time you login
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Quote
#8
(Dec-13-2016, 02:01 PM)sparkz_alot Wrote: You should be able to run this with Windows Task Scheduler for every time you login

You see the third line will open a command box. In there, you can now type stuff like python my_script.py and have it work instantly. No need to schedule the command box to open after every login. Just put the .bat file on your taskbar or desktop for easy access and be done with it.
Quote
#9
This is good stuff.
Thank you all for this information. This will save me lots of time (and headaches with my IT dept.)  Big Grin
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Getting Cells from the Sheets "automate the boring stuff" Shafla 8 232 Sep-24-2019, 04:53 AM
Last Post: snippsat
  [split] Automate the boring stuff, inserting commas in list srikanth 1 198 Jul-02-2019, 02:29 PM
Last Post: metulburr
  Regex Issue from Automate the Boring Stuff book robgraves 2 346 Jun-16-2019, 12:41 AM
Last Post: robgraves
  Help with environment path variables kuharido 0 269 Jun-07-2019, 09:18 PM
Last Post: kuharido
  Advice on Setting Up the Python Environment punksnotdead 1 284 May-15-2019, 04:29 PM
Last Post: snippsat
  Automate the boring stuff: regex not matching DJ_Qu 7 682 Apr-27-2019, 07:03 AM
Last Post: micseydel
  Automate the boring stuff : the tic tac toe game DJ_Qu 7 1,086 Apr-24-2019, 12:22 PM
Last Post: ichabod801
  Automate the boring stuff, inserting commas in list DJ_Qu 3 549 Apr-21-2019, 03:52 PM
Last Post: perfringo
  Arduino / Python Environment Setup - PIP stevealbright 0 327 Feb-24-2019, 10:48 PM
Last Post: stevealbright
  Which package installation methods to use inside a python virtual environment? python_user_03 2 579 Dec-26-2018, 03:00 PM
Last Post: gehrenfeld

Forum Jump:


Users browsing this thread: 1 Guest(s)