Bottom Page

Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 .pth file does not show up in sys.path when configuring path.
#1
Hi,

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\mypath.py)
- 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 mypath.py(C:\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.
Quote
#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
Quote
#3
@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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Add path to a local file in pop-up field pythonscripting 1 80 Feb-08-2020, 10:57 PM
Last Post: Larz60+
  Extract Httponly, Secure, domain and path from a cookie randeniyamohan 0 144 Jan-26-2020, 04:59 PM
Last Post: randeniyamohan
  How to get full path of specified hidden files matching pattern recursively SriRajesh 4 200 Jan-18-2020, 07:12 PM
Last Post: SriRajesh
  How to get file name without the full path details and without extension aruncom2006 1 144 Jan-13-2020, 07:37 AM
Last Post: Larz60+
  Downloading And Saving Zip Files To A Particular Path Folder eddywinch82 2 233 Jan-06-2020, 07:56 PM
Last Post: eddywinch82
  How to include Variable in File Path penahuse 3 235 Jan-05-2020, 03:08 AM
Last Post: ichabod801
  Finding a Hamiltonian Path Efficiently - ADVANCED stauffski 3 203 Dec-31-2019, 10:25 PM
Last Post: stauffski
  How to search full path of specified file SriRajesh 3 213 Dec-14-2019, 04:52 PM
Last Post: Gribouillis
  [split] FileNotFoundError...System cannot find the path specified powerrocker 1 212 Oct-03-2019, 09:09 AM
Last Post: buran
  run into issues while configuring visual-studio code on a win 7 machine. apollo 3 504 Sep-12-2019, 12:25 AM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)