Re: PythonPath / sys.path
On 5/15/2023 3:26 AM, Barry wrote: On 15 May 2023, at 05:39, Thomas Passin wrote: On 5/14/2023 11:08 PM, Chris Angelico wrote: On Mon, 15 May 2023 at 12:07, Thomas Passin wrote: Well, no, why would you assume that? I started to use Linux - in VMs - because I had to make sure that my cross-platform java/jython Tomcat program would work right on Linux. Why, for example, would I think to install Idle from the package manager when it, or things like that, were always in my experience installed with pip? For that matter, "sudo apt-get install pip" won't install pip. You need to use a different name, and it may or may not be different for different distros. If you EVER had to install something other than a Python package, you would have had to make use of the system package manager. You're right, there are multiple obvious ways to install Idle, but that doesn't mean that the package manager isn't one of them. Yes, after a while I came to realize that missing Python pieces might be available from the package manager. That doesn't mean it's obvious, or easy to discover just what names to use. And sometimes one has to add a new external repository. Personally, I don't find it easy to scroll through hundreds of lines in the synaptics search results looking for something whose name I can only partly guess at. If I know the command line equivalent for a search, I could do a grep and that would probably be more focused. But trying to work with a dozen different distros because various clients might use them - it's hard to keep details straight. Anyway, there's no point in trying to convince me that I could have understood everything at the start that I may have learned later. I'm just interested in passing on things I've learned along that way that a newcomer to Python in Linux may not realize. Being a Fedora user i needed to learn how to install missing pieces of pyrhon on ubuntu. We searches for: ubuntu install pip Ubuntu install idle Both provide lots of answers. Did your searches fail to turn up answers? No, that's what I had to do too, that and scan through package manager searches. -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On Mon, 15 May 2023 at 14:38, Thomas Passin wrote: > > On 5/14/2023 11:08 PM, Chris Angelico wrote: > > On Mon, 15 May 2023 at 12:07, Thomas Passin wrote: > >> Well, no, why would you assume that? I started to use Linux - in VMs - > >> because I had to make sure that my cross-platform java/jython Tomcat > >> program would work right on Linux. Why, for example, would I think to > >> install Idle from the package manager when it, or things like that, were > >> always in my experience installed with pip? For that matter, "sudo > >> apt-get install pip" won't install pip. You need to use a different > >> name, and it may or may not be different for different distros. > > > > If you EVER had to install something other than a Python package, you > > would have had to make use of the system package manager. You're > > right, there are multiple obvious ways to install Idle, but that > > doesn't mean that the package manager isn't one of them. > > Yes, after a while I came to realize that missing Python pieces might be > available from the package manager. That doesn't mean it's obvious, or > easy to discover just what names to use. Define "obvious". Nothing is completely intuitive, and at some point, you HAVE to learn things. With any modern GUI desktop system, I am going to assume that "click on the thing" counts as obvious, even though it, like everything else, has to be learned. Once it's been the exact same UI for everything so far, wouldn't it count as obvious? Use your package manager. > And sometimes one has to add a > new external repository. Why? When do you need to? Use the system package manager and the core repositories. > Personally, I don't find it easy to scroll > through hundreds of lines in the synaptics search results looking for > something whose name I can only partly guess at. I don't use Synaptic, so I have no idea what the problem is here, but there are really only a couple of plausible package names: 1) idle 2) python-idle It's possible you'll need to install idle3 or python3-idle to get the latest, but if so, one of the above names would have installed Idle from Python 2.7. This is a matter of learning patterns, which most humans are good at. But even if you haven't yet, your absolute worst case is a straight-forward search ("apt-cache search idle", "apt search idle", or using a GUI tool to search). Assuming you haven't added every repository you can find, in a wild attempt to worsen your computer's stability and security, this should produce roughly a hundred results (I got 123 on my search), many of which are clearly not what you want. This is really not that many to skim over. > If I know the command > line equivalent for a search, I could do a grep and that would probably > be more focused. Did you try searching the web for "apt search for package" or anything like that? The command is "apt search" or "apt-cache search" (they're slightly different in output but they'll give broadly the same info) and this information is easily found on the internet. > But trying to work with a dozen different distros > because various clients might use them - it's hard to keep details straight. Okay, that's fair. You should only have to work with a small number of package managers, but the more different the distros are, the less effective you'll be at intuitively guessing the package names. But you should still be able to search. > Anyway, there's no point in trying to convince me that I could have > understood everything at the start that I may have learned later. I'm > just interested in passing on things I've learned along that way that a > newcomer to Python in Linux may not realize. I'm not saying you should have understood everything at the start; but I am saying that all the answers are out there if you look for them. Making blanket statements like: > 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. are *EXTREMELY* unfair, since you are naming a single distro and then blaming "many other" distros by association, giving the highly false impression that Linux is nearly impossible to use. It is, in fact, very easy to install these things on many Linux distros. You just have to be willing to get to know your own system (since most people are only running one distro). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
> On 15 May 2023, at 05:39, Thomas Passin wrote: > > On 5/14/2023 11:08 PM, Chris Angelico wrote: >>> On Mon, 15 May 2023 at 12:07, Thomas Passin wrote: >>> Well, no, why would you assume that? I started to use Linux - in VMs - >>> because I had to make sure that my cross-platform java/jython Tomcat >>> program would work right on Linux. Why, for example, would I think to >>> install Idle from the package manager when it, or things like that, were >>> always in my experience installed with pip? For that matter, "sudo >>> apt-get install pip" won't install pip. You need to use a different >>> name, and it may or may not be different for different distros. >> If you EVER had to install something other than a Python package, you >> would have had to make use of the system package manager. You're >> right, there are multiple obvious ways to install Idle, but that >> doesn't mean that the package manager isn't one of them. > > Yes, after a while I came to realize that missing Python pieces might be > available from the package manager. That doesn't mean it's obvious, or easy > to discover just what names to use. And sometimes one has to add a new > external repository. Personally, I don't find it easy to scroll through > hundreds of lines in the synaptics search results looking for something whose > name I can only partly guess at. If I know the command line equivalent for a > search, I could do a grep and that would probably be more focused. But > trying to work with a dozen different distros because various clients might > use them - it's hard to keep details straight. > > Anyway, there's no point in trying to convince me that I could have > understood everything at the start that I may have learned later. I'm just > interested in passing on things I've learned along that way that a newcomer > to Python in Linux may not realize. Being a Fedora user i needed to learn how to install missing pieces of pyrhon on ubuntu. We searches for: ubuntu install pip Ubuntu install idle Both provide lots of answers. Did your searches fail to turn up answers? Barry > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On 5/14/2023 11:08 PM, Chris Angelico wrote: On Mon, 15 May 2023 at 12:07, Thomas Passin wrote: Well, no, why would you assume that? I started to use Linux - in VMs - because I had to make sure that my cross-platform java/jython Tomcat program would work right on Linux. Why, for example, would I think to install Idle from the package manager when it, or things like that, were always in my experience installed with pip? For that matter, "sudo apt-get install pip" won't install pip. You need to use a different name, and it may or may not be different for different distros. If you EVER had to install something other than a Python package, you would have had to make use of the system package manager. You're right, there are multiple obvious ways to install Idle, but that doesn't mean that the package manager isn't one of them. Yes, after a while I came to realize that missing Python pieces might be available from the package manager. That doesn't mean it's obvious, or easy to discover just what names to use. And sometimes one has to add a new external repository. Personally, I don't find it easy to scroll through hundreds of lines in the synaptics search results looking for something whose name I can only partly guess at. If I know the command line equivalent for a search, I could do a grep and that would probably be more focused. But trying to work with a dozen different distros because various clients might use them - it's hard to keep details straight. Anyway, there's no point in trying to convince me that I could have understood everything at the start that I may have learned later. I'm just interested in passing on things I've learned along that way that a newcomer to Python in Linux may not realize. -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On Mon, 15 May 2023 at 12:07, Thomas Passin wrote: > Well, no, why would you assume that? I started to use Linux - in VMs - > because I had to make sure that my cross-platform java/jython Tomcat > program would work right on Linux. Why, for example, would I think to > install Idle from the package manager when it, or things like that, were > always in my experience installed with pip? For that matter, "sudo > apt-get install pip" won't install pip. You need to use a different > name, and it may or may not be different for different distros. If you EVER had to install something other than a Python package, you would have had to make use of the system package manager. You're right, there are multiple obvious ways to install Idle, but that doesn't mean that the package manager isn't one of them. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On 5/14/2023 7:28 PM, Chris Angelico wrote: On Mon, 15 May 2023 at 09:22, Thomas Passin wrote: 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. The assumption on Linux is usually that you know how to use your system's package manager. And on Debian and Ubuntu specifically, it's about as easy as you would want: "apt install idle". That'll pull in everything you should need. I don't know about other distros but I would expect that it's approximately as easy. Maybe that's not obvious if you come from Windows, but I'd guess that most desktop Linux users will have at least a passing familiarity with their package manager, making this a perfectly obvious way to get new software. Well, no, why would you assume that? I started to use Linux - in VMs - because I had to make sure that my cross-platform java/jython Tomcat program would work right on Linux. Why, for example, would I think to install Idle from the package manager when it, or things like that, were always in my experience installed with pip? For that matter, "sudo apt-get install pip" won't install pip. You need to use a different name, and it may or may not be different for different distros. No, I came to use Linux they way I said, but I didn't find those things to be obvious. That's why I've started mentioning them on this list when it seems like they might be useful. Furthermore, people have been having trouble getting certain PyQt programs working on Ubuntu 22.04 (and 20.xx before it) (yes, I know, not what the OP asked about). The solution is pretty non-obvious and requires a particular .so library file to be installed, if you can discover which one and how to do that. I mention this in support of what I said about a Windows Python user being likely to find things harder, not easier, on Linux. And please, let's not start a flame war about this! I'm passing on what I've experienced, that's all. Yes, I know that there are some Python packages that need to be built and that usually works better on Linux. And I'll agree that some Python programs are snappier to load and run on Linux than on the same machine running Windows, even in a Linux VM guest. -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On Mon, 15 May 2023 at 09:22, Thomas Passin wrote: > 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. The assumption on Linux is usually that you know how to use your system's package manager. And on Debian and Ubuntu specifically, it's about as easy as you would want: "apt install idle". That'll pull in everything you should need. I don't know about other distros but I would expect that it's approximately as easy. Maybe that's not obvious if you come from Windows, but I'd guess that most desktop Linux users will have at least a passing familiarity with their package manager, making this a perfectly obvious way to get new software. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
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. -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On 5/13/23, Grizzy Adams via Python-list wrote: > > I have tried adding my dir in registry to the existing PythonPath > > [HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\PythonPath] > @="D:\\Shades\\Tools\\Python\\Lib;D:\\Shades\\Tools\\Python\\DLLs" > > that did not help, The default value of the above registry key is only used if Python can't calculate the default sys.path based on searching for "os.py", the landmark module in the standard library. This can happen sometimes when Python is embedded or run from a symlink. The default value of each subkey of "[HKCU|HKLM]\Software\Python\PythonCore\\PythonPath", on the other hand, usually does extend sys.path. Except that running Python with the -E or -I command-line options (both supported by Python 3.4) makes the interpreter ignore PYTHON* environment variables, including PYTHONPATH, as well as registry settings such as subkeys of "PythonPath". Even with the -E or -I command-line options, .pth files in the system site-packages are still processed. A .pth file can be used to extend sys.path as long as the site module is imported, i.e. as long as the -S command-line option isn't used. One difference, however, is that directories in .pth files are appended to sys.path and thus do not override the standard library. -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On 5/14/23 13:00, Grizzy Adams via Python-list wrote: Sunday, May 14, 2023 at 11:11, Mats Wichmann wrote: Re: PythonPath / sys.path (at least in part) On 5/14/23 10:43, Barry wrote: I take it you have business reasons to use an obsolete version python. Where did you get your version of python from? In fact, a *nine* year old version of Python that reached end-of-life four years ago. Just sayin' Python version shouldn't have anything to do with the sys.path, though. I must have slept a while Python 3.4.10 (default, Jul 14 2019, 14:41:03) [MSC v.1600 32 bit (Intel)] on win32 Actually I did have 3..4.3 when I asked the question (first time) because I could only find 3.4.10 as src and did not feel I was able to compile it with any certainty ;->) 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 yes, it's true that 3.4 was the last release supported on XP, so that's a pretty good reason (of course we can ask why still running XP, but I do understand old machines...) 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) IDLE is still supported, you shouldn't have any trouble getting it. https://packages.ubuntu.com/lunar/idle -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
Sunday, May 14, 2023 at 11:11, Mats Wichmann wrote: Re: PythonPath / sys.path (at least in part) >On 5/14/23 10:43, Barry wrote: >> I take it you have business reasons to use an obsolete version python. >> Where did you get your version of python from? >In fact, a *nine* year old version of Python that reached end-of-life >four years ago. >Just sayin' >Python version shouldn't have anything to do with the sys.path, though. I must have slept a while Python 3.4.10 (default, Jul 14 2019, 14:41:03) [MSC v.1600 32 bit (Intel)] on win32 Actually I did have 3..4.3 when I asked the question (first time) because I could only find 3.4.10 as src and did not feel I was able to compile it with any certainty ;->) 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 Grizz -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
On 5/14/23 10:43, Barry wrote: I take it you have business reasons to use an obsolete version python. Where did you get your version of python from? In fact, a *nine* year old version of Python that reached end-of-life four years ago. Just sayin' Python version shouldn't have anything to do with the sys.path, though. -- https://mail.python.org/mailman/listinfo/python-list
Re: PythonPath / sys.path
> On 14 May 2023, at 16:32, Grizzy Adams via Python-list > wrote: > > Hi All > > My first post (repeated) > > I am having a problem with PythonPath / sys.path > > I have a dir where I keep all my current work, but I can't seem to add it to > PythonPath / sys.path > > When I try to import one of my modules I see > import My_Working_File > Traceback (most recent call last): > File "", line 1, in >import My_Working_File > ImportError: No module named 'My_Working_File' > > I have tried adding my dir in registry to the existing PythonPath > > [HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\PythonPath] > @="D:\\Shades\\Tools\\Python\\Lib;D:\\Shades\\Tools\\Python\\DLLs" > > that did not help, > > I tried adding PYTHONPATH as an enviramental variable, that also had no effect > > (I did re-boot after these two tests) > > If I go to the editor window and run (F5) any of my modules then I can > RESTART import My_Working_File > > without error > > I can also (from a fresh start) > import sys sys.path.append(r'D:\Shades\Tools\Python\MyWork') print(sys.path) > ['', 'D:\\Shades\\Tools\\Python\\Lib\\idlelib', > 'D:\\Shades\\Tools\\Python\\python34.zip', 'D:\\Shades\\Tools\\Python\\DLLs', > 'D:\\Shades\\Tools\\Python\\lib', 'D:\\Shades\\Tools\\Python', > 'D:\\Shades\\Tools\\Python\\lib\\site-packages', > 'D:\\Shades\\Tools\\Python\\MyWork'] import My_Working_File > > I don't really want to go this route every time I start work, and more to the > point I will need (to learn how) to add dir's to the path at times > > I did search the net for an answer but only got what I had already tried > > any pointers what I'm doing wrong (other than using windows '->) I take it you have business reasons to use an obsolete version python. Where did you get your version of python from? You seem to be doing the right thing with setting an environment variable. Useless shades is an app that embeds python. Try starting cmd.exe and using the set command to liat all of the environment. Do you see your PYTHONPATH variable? Does it contain what you expect? If it does start python and check that sys.path has your folder in it. Also check what is on os.environ dirctionary. Barry > > Grizz > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list