Re: Pip installs to unexpected place

2025-04-21 Thread songbird via Python-list
Peter J. Holzer wrote:
> On 2025-04-18 13:08:36 -0400, Thomas Passin via Python-list wrote:
...
>> When the system launches its application the PYTHONPATH will start with
>> system site directories; local user site directories will be on the
>> PYTHONPATH but since they come later, the python will use PyQt6 v6.8.3
>> because that will come first on the path.  No crash here.
>> 
>> If the user has a program that actually does require the use of v6.9.0, he's
>> going to have to make sure that the user's local site directories come first
>> on the path. One way to do that is to set the PYTHONPATH to point to the
>> user's location.
>
> This is IMHO not practical. The user would have to set PYTHONPATH for
> some programs, but not for others. You can't do this with .bashrc (or
> similar), the user would have to write a wrapper script for each of
> their programs which depend on something in ~/.local. Possible of course
> but cumbersome.

  currently in my .bashrc i have it set up to look for which
directory the terminal is in and then runs the activate script
for that environment.  i like to keep my desktops/projects
open with various numbers of terminals available so this way
they are all ready to go when the system boots up.


> I like Oscar's suggestion that Python scripts provided by the
> distribution include -s in the shebang much better.
>
> Or - what I tend to do - simply use a virtual environment for each
> script that needs a package that the system doesn't provide. But of
> course that's basically "disable/don't use .local" and all those venvs
> take space and need to be maintained.

  i like that they do not change until i specificly ask them to
be changed.


...
>> The only one I can think of is for the user, with the help of sudo, or
>> by editing some system-enabled script, were to change the global
>> PYTHONPATH.  That seems a stretch.
>
> No, there doesn't have to be a global (in the sense that it applies to
> all users) PYTHONPATH for that to happen. You just need a PYTHONPATH
> that is set for all processes of that user - which the user can
> certainly set without sudo (usually by editing .bashrc or maybe using
> their desktop environment's settings dialog).

  yes, that is part of what .bashrc is for, making sure your
environment variables are set how you'd like them.


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pip installs to unexpected place

2025-04-21 Thread rbowman via Python-list
On Sat, 19 Apr 2025 15:56:16 -0400, Thomas Passin wrote:

> My problem with venvs, especially if I have more than one, is that I
> eventually forget what they were for and what is different about each
> one. If there's only one and it's used for all non-system work, that's
> OK but beyond that and they tend to suffer knowledge rot.

My Python directory has

apple/   create/  fastapi/  lunar/  numerical/  pyside6/  weather/
comics/  django/  folium/   ml/  sqlite/  coursera/  impractical/
nn/  pyqt/  torch/

Not all like sqlite are venvs since no additional modules are needed. Even 
if I'm a little hazy about 'apple' after a while a quick look at the 
Python file shows 'https://itunes.apple.com/search' and I remember it is 
to pull down artist/track info from the itunes database.

I also try to remember to run 'pythom -m pip freeze > requirements.txt' 
after I get everything set up. That way if a OS update installs a new 
version of Python  something like

python3 -m venv folium
cd folium
. bin/activate
python -m pip install -r requirements.txt

will refresh the venv and install the appropriate packages for the new 
Python version. That's faster than looking at lib/python3.10/site-packages 
or whatever the previous version was and adding the dependencies  or 
trying to run the py file and getting

Traceback (most recent call last):
  File "/home/rbowman/work/python/impractical/benford.py", line 5, in 

import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'







-- 
https://mail.python.org/mailman/listinfo/python-list