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.

I am just beginning to learn Python and I ran into a problem related to configuring path. Here is a quick background and other details:

- I have 3.6.2 running on windows
- I tried to extend the path using a simple mypath.pth txt file(Contains: C:\Users\Arjun)
- I tried saving it in the top level Python install directory(C:\...\python36-32\
- I also tried saving it in site-packages(C:\...\python36-32\Lib\site-packages)
- In both the cases when I try to review whether it worked(IDLE and command line) using sys.path, it does not show the contents of\Users\Arjun) in the output
- I can see current directory(''), standard modules, PYTHONPATH I configured and site-packages at last, but not the .pth file

Please help me with the issue as I am not sure where I am going wrong. I am beginner and would appreciate all the help I can get.
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 file in C:\Python37\Lib\site-packages or your site-packages folder.
import site

Test that it work.
λ ptpython
>>> import sys
>>> from pprint import pprint

>>> pprint(sys.path)
For OS and Path look at Python 3.6/3.7 and pip installation under Windows
@Snippsat: Wow, this looks way more convenient and it works great. Thanks again man, as I said, I am new to Python and had no clue this module existed.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Virtual environment path? Led_Zeppelin 1 336 Jul-22-2021, 01:40 PM
Last Post: snippsat
  (Path?)Problems with dockerizing a python app sgofferj 0 155 Jul-19-2021, 10:02 AM
Last Post: sgofferj
  get all the files in the path in a list? korenron 23 785 Jul-19-2021, 07:44 AM
Last Post: korenron
  Defining path erdemath 2 307 Jul-12-2021, 04:55 PM
Last Post: Gribouillis
  deleting an empty Dir, using pathlib.Path tester_V 9 382 Jul-01-2021, 01:53 PM
Last Post: Gribouillis
Exclamation Path sacn problem lucky511 10 544 Jun-24-2021, 12:09 PM
Last Post: Axel_Erfurt
  Trying to pathlib instead of os.path tester_V 4 265 Jun-22-2021, 04:15 AM
Last Post: tester_V
  'import Path' do not understand how to use it tester_V 2 198 Jun-19-2021, 02:23 AM
Last Post: tester_V
  sys.path.insert() Skaperen 2 618 Jun-03-2021, 06:49 AM
Last Post: Gribouillis
  extra slashes in the network path for shutil.copy tester_V 3 429 Jun-02-2021, 07:57 AM
Last Post: supuflounder

Forum Jump:

User Panel Messages

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