Python Forum
using self-developed modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using self-developed modules
#12
(Aug-30-2019, 04:16 PM)wlp Wrote: But when I display in Python "pprint (sys.path)", the folder does not show up.
Strange!
No it's not strange,there is no connection between Environment Variables(OS) and sys.path(Python).
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)
800
As 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\
Reply


Messages In This Thread
using self-developed modules - by wlp - Aug-28-2019, 03:04 PM
RE: using self-developed modules - by wlp - Aug-28-2019, 04:05 PM
RE: using self-developed modules - by snippsat - Aug-28-2019, 05:41 PM
RE: using self-developed modules - by wlp - Aug-29-2019, 10:36 AM
RE: using self-developed modules - by perfringo - Aug-29-2019, 11:22 AM
RE: using self-developed modules - by snippsat - Aug-29-2019, 03:29 PM
RE: using self-developed modules - by wlp - Aug-29-2019, 04:18 PM
RE: using self-developed modules - by snippsat - Aug-29-2019, 05:20 PM
RE: using self-developed modules - by wlp - Aug-30-2019, 02:18 PM
RE: using self-developed modules - by snippsat - Aug-30-2019, 03:17 PM
RE: using self-developed modules - by wlp - Aug-30-2019, 04:16 PM
RE: using self-developed modules - by snippsat - Aug-30-2019, 07:10 PM
RE: using self-developed modules - by wlp - Aug-31-2019, 01:45 PM
RE: using self-developed modules - by snippsat - Aug-31-2019, 05:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Developed App in VS2019 - Help with pyinstaller fioranosnake 0 1,630 Nov-11-2019, 09:12 PM
Last Post: fioranosnake
  Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 bmohanraj91 6 8,520 May-25-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020