I actually was executing the pip with the venv activated. I had created the venv without copying over the main package distribution. So I recreated it doing that copy-over and then the install succeeded. It gave a warning that the package had been installed in /home/pi/.local/bin and I should add that to my $PATH., which I did."this environment is externally managed".means you are executing the command in a terminal with the venv not activated.
Strange (at least to this Linux noob) is that now my Python programs that use the sensor work WITHOUT having the venv activated. (???) It's like the venv was only needed for the install. Does that make sense?
I look in /home/pi/.local/bin and the only file there is: w1thermsensor, of type plain text, and here is what it contains:I'm glad it works but sure don't understand it!Code:
#!/home/pi/Documents/HVAC/env/bin/python# -*- coding: utf-8 -*-import reimport sysfrom w1thermsensor.cli import cliif __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(cli())
I don't know what this file is called (maybe you posted the name somewhere up there and I just did not look), but it is a python entry point script which wraps the actual execution of a python script with something akin to
Code:
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
If you edit that script from this:
Code:
#!/home/pi/Documents/HVAC/env/bin/python# -*- coding: utf-8 -*-import reimport sysfrom w1thermsensor.cli import cliif __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(cli())
[/quote]
to this:
Code:
#!/home/pi/Documents/HVAC/env/bin/python# -*- coding: utf-8 -*-import reimport sysfrom w1thermsensor.cli import cliif __name__ == '__main__': print("before", sys.argv) sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) print("after", sys.argv) sys.exit(cli())
Here's a nice simple read on python entry points and you can code along if you don't want to just read it (I learn better with code alongs) https://amir.rachum.com/python-entry-points/
For a more technical short background on it https://packaging.python.org/en/latest/ ... ry-points/
Statistics: Posted by memjr — Sat Aug 03, 2024 4:59 pm