Re: Correct module for site customization of path

2024-11-01 Thread Tim Johnson via Python-list

On 11/1/24 08:32, dieter.mau...@online.de wrote:

...
After the recent upgrades I had to install youtube_dl with pipx for the
new python version.
When I ran the script which imported youtube_dl, I got an import error
as it appears the path to the module
was not in sys.path

I see at several options:

  * install `youtoube_dl` where Python looks for it
(you can print `sys.path` to find out all the places
normally checked for importable modules)

  * put a (symbolic) link to `youtoube_dl` at a place
where Python looks for modules

  * use Pythons' `.pth' feature to tell Python additional
places where to look for modules.
You can place `.pth` files where Python looks for modules
to be imported

In  /usr/lib/python3.12/sitecustomize.py I put the following:
import sys
sys.path.append("path to youtube_dl")
# In /usr/lib/python3.12/sitecustomize.py
# Thanks seems to work for me
cheers


--
Tim
thjmm...@gmail.com

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


Correct module for site customization of path

2024-10-31 Thread Tim Johnson via Python-list
FYI: I am retired programmer using a recent upgrade to ubuntu 24.04 and 
python 3.12
My needs are that of a hobbyist at this time. I am on a single user home 
desktop with root privileges available.


After the recent upgrades I had to install youtube_dl with pipx for the 
new python version.
When I ran the script which imported youtube_dl, I got an import error 
as it appears the path to the module
was not in sys.path. For me,  it was a simple matter of appending the 
path for youtube_dl to sys.path, however,

I would prefer to not have to do an append at every script using it.

There is a boatload of documentation of site path configuration, but 
still, I am not sure what option to take.

Recommendations are invited and welcome.

Thanks

--
Tim
thjmm...@gmail.com
--
https://mail.python.org/mailman/listinfo/python-list


Re: ModuleNotFoundError for youtube_dl

2024-12-09 Thread Tim Johnson via Python-list


On 12/9/24 14:59, Tim Johnson wrote:


Recently did a refresh of ubuntu 24.04

With no code changes am now getting a *ModuleNotFoundError *for youtube_dl

Relevant code is

import sys
sys.path.append("/home/tim/.local/share/pipx/venvs/youtube-dl/lib/python3.12/site-packages/youtube_dl")

import youtube_dl '

Navigating to 
/home/tim/.local/share/pipx/venvs/youtube-dl/lib/python3.12/site-packages/youtube_dl,


I see the following

tim@beelink:~/.local/share/pipx/venvs/youtube-dl/lib/python3.12/site-packages/youtube_dl$ 
ls
aes.py    compat.py   extractor    jsinterp.py  options.py 
__pycache__  swfinterp.py  utils.py    YoutubeDL.py
cache.py  downloader  __init__.py  __main__.py  postprocessor 
socks.py update.py version.


I should not have appended 'youtube_dl' to the path. I used the content 
from 
/home/tim/.local/share/pipx/shared/lib/python3.12/site-packages/pipx_shared.pth


("/home/tim/.local/share/pipx/shared/lib/python3.12/site-packages") and 
added that to /usr/lib/python3.12/sitecustomize.py as appended to sys.path


and it appears to be solved.
--
https://mail.python.org/mailman/listinfo/python-list


ModuleNotFoundError for youtube_dl

2024-12-09 Thread Tim Johnson via Python-list

Recently did a refresh of ubuntu 24.04

With no code changes am now getting a *ModuleNotFoundError *for youtube_dl

Relevant code is

import sys
sys.path.append("/home/tim/.local/share/pipx/venvs/youtube-dl/lib/python3.12/site-packages/youtube_dl")

import youtube_dl '

Navigating to 
/home/tim/.local/share/pipx/venvs/youtube-dl/lib/python3.12/site-packages/youtube_dl,


I see the following

tim@beelink:~/.local/share/pipx/venvs/youtube-dl/lib/python3.12/site-packages/youtube_dl$ 
ls
aes.py    compat.py   extractor    jsinterp.py  options.py __pycache__  
swfinterp.py  utils.py    YoutubeDL.py
cache.py  downloader  __init__.py  __main__.py  postprocessor 
socks.py update.py version.py


I've been retired from python programming for 10 years now, and just 
tinker or write stuff for myself to


use on my own workstation, so I have obviously forgotten a lot (if you 
don't use it you lose it, right)


I hope that someone can help me correct this.

thanks

tim

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


Re: subprocess.Popen does not launch audacity

2025-01-10 Thread Tim Johnson via Python-list


On 1/10/25 12:53, Thomas Passin via Python-list wrote:

On 1/10/2025 4:00 PM, Tim Johnson via Python-list wrote:


On 1/10/25 11:32, MRAB via Python-list wrote:

,,, snipped



Below is the pertinent code:

   Popen(choice, stdout=PIPE, stderr=PIPE,
    stdin=PIPE, close_fds=True)

My guess is my argument list is either insufficient or an argument is
causing the problem, but am unsure of which.

I have been retired from python programming for ten years, and am 
pretty

rusty, but it is still fun. There are plenty

of other ways to successfully launch audacity but it would be great to
make it work from this script.



What is the value of 'choice'?

You could try printing out the value of 'choice' for one that works 
and the one that doesn't and then try them again interactively from 
the Python prompt with the given values. That should eliminate all 
but the essential code for easier debugging.


choice is /usr/local/bin/audacity, which is the correct path for 
audacity on my system. As far as I can see, that string has no hidden 
bytes.


Invoking /usr/local/bin/audacity from the command line launches 
audacity and so does choosing  with dmenu_run. which -a audacity 
shows only that item.


Maybe I need to isolate the function call and start stripping out 
parameters. I should have time to do that later today.


I don't know why you would want to redirect stdin, etc.  It's a GUI 
application.


This worked for me in a Python session on EndeavourOS, python 3.13.1:

>>> from subprocess import run
>>> run('/usr/bin/audacity')


You're right as I suspected. The input files that I am using need a flag 
field to indicate whether the target


is a gui or terminal app. Removing the pipe parameters gave me audacity 
just fine. Time to roll up my sleeves


and get to work adding the relevant code. Beats shoveling snow. :)

Thanks everybody.





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


Re: No module name mutagen

2025-01-01 Thread Tim Johnson via Python-list



On 12/31/24 15:00, Tim Johnson wrote:

. Snipped

I resolved this by extrapolating known paths of other non-distro pipx 
installs, and am back


in business now. I'm taking lots of notes. For some reason, even after 
running updatedb,


I had no luck finding with locate.

I was not aware that mutagen is available through apt. Thanks to you who 
brought that up.


I have noted some other things: Running pipx with the verbose flag gives 
me more information,


and probably would have been enough to not require me to post this 
thread. *And: *the verbose


flag tells me where the logs are. Whoopee!


Seems to me it wouldn't be that hard for pipx to print out the full 
install path, both at install runtime and


in the log. Oh well, if I didn't have problems, I would use my 
pythonisto brain even less and it


would atrophy even further.


Thanks for all the input. Happy New Year, one and all. :)

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


No module name mutagen

2024-12-31 Thread Tim Johnson via Python-list
Please let me grumble for a minute : I've been using python since before 
1. 5, when I could email Guido van Rossum directly with questions


and on  at least one occasion we swapped stories about our cats. I put 
six kids though college writing python, and now after


being retired for ten years, I get my butt kicked by python dependencies 
every time I upgrade ubuntu. (I'm newly on 24.04) now.


Now, after three weeks on using the following code correctly:

from mutagen import mp3, id3, File as mutaFile
from mutagen.id3 import ID3, TIT2, TPE1

I am as of today, getting an import error for mutagen. Mutagen package 
is installed at /root/.local/share/pipx/shared/lib/python3.12/site-packages


and indeed, that is the content of 
/root/.local/share/pipx/shared/lib/python3.12/site-packages/pipx_shared.pth


I have added that to my path and am still getting the error. Grrr...

I am at a loss. don't know what to do. I am only using python script for 
command line utilities on my desktop and local network.


Must I be using a virtual environment? If so, I would be happy to set 
one up if I am given the python-approved directions


(lots of conflicting info out there)

Thanks

Tim



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


subprocess.Popen does not launch audacity

2025-01-10 Thread Tim Johnson via Python-list

Using Python 3.12.3 on Ubuntu 24.04

I've converted a legacy python2 script to python3. All went well. 
However, a glitch from python2 remains.


The script uses dmenu to create menus to pick applications. Applications 
are then invoked from python


using subprocess.Popen(). I have never been able to successfully launch 
audacity using this approach,


which does work for other apps.

I can launch audacity successfully using dmenu_run (on its own, outside 
of the script)


Below is the pertinent code:

 Popen(choice, stdout=PIPE, stderr=PIPE,
  stdin=PIPE, close_fds=True)

My guess is my argument list is either insufficient or an argument is 
causing the problem, but am unsure of which.


I have been retired from python programming for ten years, and am pretty 
rusty, but it is still fun. There are plenty


of other ways to successfully launch audacity but it would be great to 
make it work from this script.


Thanks in advance

Tim

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


Re: subprocess.Popen does not launch audacity

2025-01-10 Thread Tim Johnson via Python-list


On 1/10/25 11:32, MRAB via Python-list wrote:

,,, snipped



Below is the pertinent code:

   Popen(choice, stdout=PIPE, stderr=PIPE,
    stdin=PIPE, close_fds=True)

My guess is my argument list is either insufficient or an argument is
causing the problem, but am unsure of which.

I have been retired from python programming for ten years, and am pretty
rusty, but it is still fun. There are plenty

of other ways to successfully launch audacity but it would be great to
make it work from this script.



What is the value of 'choice'?

You could try printing out the value of 'choice' for one that works 
and the one that doesn't and then try them again interactively from 
the Python prompt with the given values. That should eliminate all but 
the essential code for easier debugging.


choice is /usr/local/bin/audacity, which is the correct path for 
audacity on my system. As far as I can see, that string has no hidden bytes.


Invoking /usr/local/bin/audacity from the command line launches audacity 
and so does choosing  with dmenu_run. which -a audacity shows only that 
item.


Maybe I need to isolate the function call and start stripping out 
parameters. I should have time to do that later today.


Thanks

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