(Aug-30-2019, 04:16 PM)wlp Wrote: But when I display in Python "pprint (sys.path)", the folder does not show up.No it's not strange,there is no connection between Environment Variables(OS) and sys.path(Python).
Strange!
Example i have a folder
C:\nc
in System Variables Path.Same code as before saved as
eggs.py
in this folder.# eggs.py def f1(x): x = x + 1 return x
C:\Users\Tom λ python Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import eggs Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'eggs' # Most add nc to sys.path,so python find it >>> import sys >>> sys.path.append(r'C:\nc') # Only temporarily added in this session # Now it work >>> import eggs >>> eggs.f1(799) 800As i explain link before in this post.
Using site will add folder permanent to
sys.path
,this mean that dos not need to add a folder to System or User Variables Path.As long as Python is System Variables as eg you have here:
C:\Users\actname\AppData\Local\Programs\Python\Python37-32\Scripts\; C:\Users\actname\AppData\Local\Programs\Python\Python37-32\