1

I would like to import some functions I regularly use into my scripts, instead of having to paste them in it. This is the reading I get when I check with the path browser:

>>> sys.path

C:\Users\Apex\AppData\Local\Programs\Python\Python37-32\Lib\idlelib
C:\Users\Apex\AppData\Local\Programs\Python\Python37-32\python37.zip
C:\Users\Apex\AppData\Local\Programs\Python\Python37-32\DLLs
C:\Users\Apex\AppData\Local\Programs\Python\Python37-32\lib
C:\Users\Apex\AppData\Local\Programs\Python\Python37-32
C:\Users\Apex\AppData\Local\Programs\Python\Python37-32\lib\sitepackages

I'd like to permanently add the following path to it:

C:\Users\Apex\AppData\Local\Programs\Python\Python37-32\PythonScripts

I've tried the following:

path = 'C:/Users/Apex/AppData/Local/Programs/Python/Python37-32/PythonScripts'
import sys, os
sys.path.append(path)

All the paths above and the one I want to add appear in the shell, but when I check the path browser, mine isn't there.

How can I set PythonScripts to Python's path permanently?

I read up a bit on PYTHONPATH, but I didn't understand how to use it. Please, when you reply, don't I assume I might know everything you do. Thanks.

Bert_AT
  • 95
  • 8
  • Could be that the path doesn't exist? Try adding the path in the folders and then running the command – Trooper Z Jul 30 '18 at 20:56
  • The path exists in the system. I created the folder. Also I can find it with the cmd prompt. But when I browse the path with the shell's path or module browsers I can't find either the path nor the module. – Bert_AT Jul 30 '18 at 20:59
  • 1
    Try changing the name path to something else, because you have `sys.path` where you can't do that to a variable and it glitches – Trooper Z Jul 30 '18 at 21:04
  • 1
    `sitepackagApex` is definitely not a normal thing to see in a `sys.path`. – user2357112 Jul 30 '18 at 22:49
  • 1
    Possible duplicate of [How to add to the pythonpath in Windows?](https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows) – Tom Zych Jul 30 '18 at 22:59
  • @Tom Zych That helped with modifications. Thanks. :) – Bert_AT Jul 31 '18 at 10:29
  • @user2357112 Thanks for pointing that out! It was a copy and paste typo. I already fixed ti. – Bert_AT Jul 31 '18 at 10:33
  • @Trooper Z your suggestion partially help solving the prolbem. Thanks. :) – Bert_AT Jul 31 '18 at 10:35

1 Answers1

1

I'm using window 7 with Python v3.7.0

Just in case that this might help someone else, this is what worked for me:

I moved the PythonScripts folder out of the Python37-32 and into the Apex folder, and I added the path to it and to another folder to the Windows Environment Viariables like this:

Variable name: PYTHONPATH
Variable value: C:\Users\Apex\PythonScripts;C:\xampp\htdocs\PythonScripts

The suggestion given in the posting I was pointed to of using:

 C:\Python27

did not work for me.

Thanks to all for their valuable input.

Bert_AT
  • 95
  • 8