Python Forum
.pth file does not show up in sys.path when configuring path.
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.pth file does not show up in sys.path when configuring path.
#2
I find it easiest to not mess with PYTHONPATH for adding own folders permanently.
The site module offers a method that takes care of adding to sys.path without duplicates and with .pth files.
Make a sitecustomize.py file in C:\Python37\Lib\site-packages or your site-packages folder.
# sitecustomize.py
import site

site.addsitedir(r'E:\div_code')
Test that it work.
C:\
λ ptpython
>>> import sys
>>> from pprint import pprint

>>> pprint(sys.path)
['C:\\python37\\Scripts\\ptpython.exe',
 'c:\\python37\\python37.zip',
 'c:\\python37\\DLLs',
 'c:\\python37\\lib',
 'c:\\python37',
 'c:\\python37\\lib\\site-packages',
 'E:\\div_code']
For OS and Path look at Python 3.6/3.7 and pip installation under Windows
Reply


Messages In This Thread
RE: .pth file does not show up in sys.path when configuring path. - by snippsat - Jul-02-2018, 09:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How does venv update $PATH without activating on Windows? bottomfeeder 3 623 Mar-13-2025, 01:46 PM
Last Post: DeaD_EyE
  Path must be screwed up somewhere BR549py 4 1,879 Sep-09-2024, 04:58 PM
Last Post: deanhystad
  os.path.exists fails with accented characters glenndrives 11 2,557 Sep-03-2024, 05:30 PM
Last Post: glenndrives
  Dictionary using path. Bobbee 5 971 Aug-22-2024, 08:43 PM
Last Post: Bobbee
  import a function from another file using relative path paul18fr 6 2,612 Aug-01-2024, 06:40 AM
Last Post: paul18fr
  Pandas ExcelWriter path name rejected morningglory 0 688 Jul-15-2024, 06:36 PM
Last Post: morningglory
  Using OpenCV and image path is invalid AudunNilsen 5 1,836 Mar-18-2024, 05:28 PM
Last Post: snippsat
  Path Planning prachibhanaria 0 776 Jan-23-2024, 10:11 AM
Last Post: prachibhanaria
  Create dual folder on different path/drive based on the date agmoraojr 2 1,273 Jan-21-2024, 10:02 AM
Last Post: snippsat
  working directory if using windows path-variable chitarup 2 1,447 Nov-28-2023, 11:36 PM
Last Post: chitarup

Forum Jump:

User Panel Messages

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