PythonPath / sys.path

Thomas Passin list1 at tompassin.net
Sun May 14 19:04:08 EDT 2023


On 5/14/2023 3:00 PM, Grizzy Adams via Python-list wrote:
> Sunday, May 14, 2023  at 11:11, Mats Wichmann wrote:
> Re: PythonPath / sys.path (at least in part)
[snip]
> I have since moved up (a little) so only ~4 years old, I then updated pip from
> 9.x to 19.1
> 
> reason its an old version is it's an old PC (XpPro), if I start to get passable
> 
> at this I will try it on my Ubuntu box which is running 22.04 (latest LTS) and
> 23.04, (23.10 daily builds soon) I took a look and it seems I "may" have to
> play a little to get IDLE on (if it's not in the normal repo's)
> 
> I seem to have managed to sort "PythonPath / sys.path" the environment variable
> 
> is working, so I can now import my_work without any other hassle, which is
> good, now I find that some of the files which worked a treat from GUI, Editor
> (F5) or terminal but don't do the same once saved and imported later, I'm sure
> it's me, I have come from VB/VBA, Delphi and a (very) little C++, and am still
> working through the python tutorial, trying not to skip ahead (ok I did skip
> "Hello World" :->) so I may end up asking some (senior moment) newbie
> questions, I will try hard to work it out myself first
> 
> Thanks to all who got me thus far

Good to hear you can run your program.  For future reference, when you 
talked about setting PYTHONPATH, it would have been helpful to know just 
what you did when you tried to set it.

If you plan to use this directory location much of the time, two good 
ways to do so are 1) putting that path in a .pth file in the 
site-packages directory, or 2) launching Python using a batch file that 
sets PYTHONPATH first, then runs Python.  On Windows, in a batch file 
you should use SETLOCAL before setting PYTHONPATH and ENDLOCAL at the 
end of the batch file.  That's the easiest way to remove the PYTHONPATH 
variable after you are done with it.

You made a little slam against Windows, but you will find it harder to 
get things working on Linux.  Ubuntu, like many other Linux distros, 
does not come with pip and Tk (needed for Idle) installed, and it's not 
so obvious how to install them.

For your old computer, I added an external 1TB solid state drive (Note: 
not  a usb stick) to a decade-old Sony VAIO and installed Linux Mint to 
the SSD.  It's got pretty decent responsiveness and all the old hardware 
is supported out of the box.



More information about the Python-list mailing list