Re: Checking if email is valid

2023-11-06 Thread rbowman via Python-list
On Sun, 5 Nov 2023 19:22:49 -0600, D'Arcy Cain wrote:

> Gotta wonder for sure.  It could also be the case of programmers
> depending on user input but the users insist on living with the bugs
> and/or working around them.  We made crash reporting dead simple to
> report on and still users didn't bother.  We would get the traceback and
> have to guess what the user was doing.

We've found even if you directly ask the user often the answer is 'I 
dunno' or some mythology they have constructed to explain the problem. We 
had one site that reported if they hit the Enter key hard the query would 
work. It was a rather simple bug where the query would be randomly sent to 
the wrong interface.

There is quite a bit of literature in psychology about intermittent 
reinforcement and the behavioral strategies that are developed. Works for 
rats, works for humans. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking if email is valid

2023-11-06 Thread rbowman via Python-list
On Tue, 7 Nov 2023 12:11:18 +1300, Greg Ewing wrote:

> On 6/11/23 6:34 pm, rbowman wrote:
>> We've found even if you directly ask the user often the answer is 'I
>> dunno' or some mythology they have constructed to explain the problem.
> 
> This seems to apply to hardware issues as well. Louis Rossmann has a
> philosophy of "Never believe what the customer tells you."

Truer words... A customer called to report an industrial dielectric heater 
wasn't putting out full power. First question was 'Did you check the 
fuses?' since it was three phase but if you blew one leg it would still 
operate on reduced power. He assured me he had. I went through the rest of 
the common problems with no solution so the next day I flew out to the 
plant. I replaced the 30 amp fuse and all was good. The customer had a 
very expensive lesson in how to check fuses. 

At least with software you don't have to physically appear on site.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-23 Thread rbowman via Python-list
On Fri, 22 Dec 2023 17:27:58 -0700, Michael Torrie wrote:

> Using the py launcher as your Windows association with .py and.pyw files
> you can have multiple versions of python installed and everything works
> as it should, according to your shebang, just like on Unix.

Does that work with virtualenv or conda? I'm slowly getting up to speed 
with those.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-25 Thread rbowman via Python-list
On Sun, 24 Dec 2023 22:55:34 +, Barry wrote:

>> On 24 Dec 2023, at 00:54, rbowman via Python-list
>>  wrote:
>> 
>> Does that work with virtualenv or conda? I'm slowly getting up to speed
>> with those.
> 
> Conda is its own thing, not need for py.exe.
> 
> Once you have created the venv you do not need py.exe as you will have
> pythob.exe in the venv bin folder.


Thanks. That's what I have been doing and have never used py.exe. For 
context Esri distributes ArcPy as a scripting language using 3.9. By 
default the base install can't be modified so if you want additional 
libraries or a tool like Spyder it has to be in a virtual. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How/where to store calibration values - written by program A, read by program B

2023-12-28 Thread rbowman via Python-list
On Wed, 27 Dec 2023 03:53:42 -0600, Greg Walters wrote:

> The biggest caveat is that the shared variable MUST exist before it can
> be examined or used (not surprising).

There are a few other questions. Let's say config.py contains a variable 
like 'font' that is a user set preference or a calibration value 
calculated by A to keep with the thread title. Assuming both scripts are 
running, how does the change get propagated to B after it is set in A and 
written to the shared file? Is there a mechanism to allow both scripts to 
make updates?

The easy way out is to assume the changes will be picked up when the 
scripts are restarted but this is not always acceptable.

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


Re: new here

2024-08-20 Thread rbowman via Python-list
On Tue, 20 Aug 2024 23:26:39 +0100, Daniel wrote:

> New here. I've perused some posts and haven't seen a posting FAQ for
> this NG. I'm learning python right now to realize some hobby goals I
> have regarding some smolnet services. What are the NG standards on
> pasting code in messages? Do yall prefer I post a pastebin link if it's
> over a certain number of lines? I know this isn't IRC - just asking.


Standards? This is usenet, the last remaining wild west. Good news: c.l.p 
isn't overrun by trolls.  Bad news: c.l.p doesn't seem to be overrun by 
much of anybody.


smolnet, as in things like 

https://small-tech.org/

Python certainly has the tools. You can even construct a web server on a 
Raspberry Pi Pico but I don't know any specifics about smolnet. The 
subreddit seems dead and I don't see anything but a few obscure github 
references.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-20 Thread rbowman via Python-list
On Tue, 20 Aug 2024 23:16:48 -0400, avi.e.gross wrote:

> I do wonder if the people at python.org want multiple forums. There is
> also one that sort of tutors people that obviously has an overlapping
> but different audience.

https://realpython.com/

That's a mixed bag. Joining is $50 USD/month or $300/year but there are 
also many tutorials that can be accessed for free. Personally I can't 
justify the cost but it does add a community chat and Q&A with a 'Python 
Expert'.

https://pycoders.com/

That's free and is more general information but some of the articles may 
be pertinent. 

@pycoders and @thepycoders on X tend to overlap the newsletter. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-22 Thread rbowman via Python-list
On Wed, 21 Aug 2024 22:04:14 +0100, Daniel wrote:

> I am on forums but tend to stay away from them unless I absolutely have
> to. I like newsgroups as they are - though I have noticed a massive drop
> in users ever since Google dropped their groups service. I also saw a
> minor drop in spam.

Absolutely. It was sort of an intelligence test. I've used the server at 
the Freie Universität Berlin from back in the days when it was free rather 
than 10 Euros a year so life went on smoothly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-22 Thread rbowman via Python-list
On Wed, 21 Aug 2024 22:15:37 +0100, Daniel wrote:

> Lesser used protocols not known by many in the mainstream. Such as:
> 
> gopher, gemini, finger, spartan, titan, etc.
> 
> An example of use, here's a weather service tied to a finger. Put your
> city name as the user. This isn't mine, but it is inspiring. Example:
> 
> finger mi...@graph.no
> 
> For all options, go to the help finger:
> 
> finger h...@graph.no

Thanks. Interesting. I was surprised a Norwegian site would have data for 
a small city in the US. I have a Python script that accesses the NOAA 
(National Oceanic and Atmospheric Administration) API and the data in the 
Meteogram appears to match well. fwiw, all that does is

   observation_url = f"https://api.weather.gov/stations/K{grid_id}/
observations/latest"
response = requests.get(observation_url).json()

using the Python 'requests' package and then parsing out the JSON.  
Implementing finger probably would be a straight socket connection. I 
don't know how useful this is: 

https://pypi.org/project/pyfinger/

I assume gopher is fron the archie, veronica, and jughead days. It appears 
straightforward.

https://datatracker.ietf.org/doc/html/rfc1436

It's another use of a simple socket connection.

https://docs.python.org/3/howto/sockets.html

You may be able to gleam something from

https://sr.ht/~lioploum/offpunk/



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


Re: new here

2024-08-22 Thread rbowman via Python-list
On Thu, 22 Aug 2024 13:43:59 +1200, dn wrote:

> The OpSys on this machine no longer features finger (available for
> installation as an 'extra').

My Ubuntu 22.04 box has it, the Fedora 40 one doesn't. Ubuntu offers to 
install gopher, Fedora doesn't. Go figure. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-22 Thread rbowman via Python-list
On Thu, 22 Aug 2024 10:40:52 -0700, Paul Rubin wrote:

> The Pico uses MicroPython which is stuck on an old version of Python,
> unfortunately.

I think it's up to 3.4 in general and erratic past that. It doesn't have 
the match from 3.10.  I don't think it has f-strings though it may have 
the walrus. There are workarounds but it can be annoying. 

I haven't worked with CircuitPython lately and don't know if it has pulled 
in later features. 

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


Re: new here

2024-08-22 Thread rbowman via Python-list
On Thu, 22 Aug 2024 09:10:00 +0100, Daniel wrote:

> If you have lynx, you can visit this gopher interface to Wikipedia:
> 
> gopher://gopherpedia.com

Yeah, that works and I could find Hillbilly Elegy (film). The text was 
fine but the 'Accolades' table was garbled. It came up on the Netflix 
recommendations and I watched it last night so when it said 'Search' I 
wanted to see what it would do. It came back with links to the book, the 
film, the Vances, and cast member bios.  It's a subset of the Wiki 'Search 
in..' but still impressive. 

Python certainly will get the job done either on the client or server 
side. Being retro tech should make life easier than some of the web 
services frameworks. 

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


Re: new here

2024-08-22 Thread rbowman via Python-list
On Fri, 23 Aug 2024 08:36:02 +1200, dn wrote:

> On 23/08/24 07:49, rbowman via Python-list wrote:
>> On Thu, 22 Aug 2024 10:40:52 -0700, Paul Rubin wrote:
>> 
>>> The Pico uses MicroPython which is stuck on an old version of Python,
>>> unfortunately.
> 
> How did this enter the conversation/thread?
> 
> Paul's 'contribution' does not even appear on the Archive...

I'm probably guilty. I mentioned in passing the older protocols like 
finger could even be implemented on something like the Pico W with 
MicroPython.

I am confused by the cross-over to Python-list. I only read/post to 
comp.lang.python. Is that echoed to Python-list or vice versa?

>> I haven't worked with CircuitPython lately and don't know if it has
>> pulled in later features.
> 
> Have you (gentle reader) used both and feel able to offer a comparison -
> when to prefer one over the other?

I've only used CircuitPython on the Adafruit Playground Express.

https://circuitpython.org/board/circuitplayground_express/

and MicroPython on the Pico W. Since then Adafruit has expanded their 
collection of boards and support them with CircuitPython.

One difference that makes them hard to compare is the Express has quite a 
few on-board sensors like the Arduino Nano Sense 33, and interfaces to 
them are baked into CircuitPython. 

The Pico W has a wealth of I/O most doubling as I2C, PWM, or A/D with only 
a onboard LED for the mandatory 'hello world' blink code. MicroPython is 
more generic and you may have to import modules for specific external 
devices like the SSD1306 OLED display. That's easily done with Thonny or 
pipkin.

As far as core Python I'd say they're similar. MicroPython is more generic 
and may require more work to set up where Adafruit can match the boards 
they have developed. 

As I said it's been a while but MicroPython has the _threading module so 
you can utilize both cores of the RP2040. Adafruit's new Feather has a 
RP2040 and like the Pico W assumes you'll be using the PIO to externals 
rather than anything onboard so CircuitPython probably has it.

https://www.adafruit.com/product/4884

>From the horse's mouth:

"There is great C/C++ support, unofficial (but really good) Arduino 
support, an official MicroPython port, and a CircuitPython port! We of 
course recommend CircuitPython because we think it's the easiest way to 
get started and it has support with most of our drivers, displays, 
sensors, and more, supported out of the box so you can follow along with 
our CircuitPython projects and tutorials."

I don't know if Adafruit has a RP2350 board yet but they say CircuitPython 
will be even happier on the Pico 2.

https://www.adafruit.com/product/6006

For better or worse there are a lot more choices now than fiddling around 
with the Arduino Uno back in the day. 







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


Re: new here

2024-08-25 Thread rbowman via Python-list
On Thu, 22 Aug 2024 19:56:54 -0700, Paul Rubin wrote:

> With MicroPython on the Pico, you use some command line utility to
> transfer files instead, but it is no big deal.

Loading the UF2 is easy.

https://www.raspberrypi.com/documentation/microcontrollers/
micropython.html

I use VS Code with the MicroPython extension so when the board is plugged 
in it shows up as ttyACM0 or COM something I think on Windows. If you need 
a package for a peripheral the file structure on the actually device shows 
up so you can copy it to the lib directory.

https://pypi.org/project/pipkin/

pipkin is the command line utility. Thonny isn't my favorite IDE but it 
does make life easy:

https://projects.raspberrypi.org/en/projects/getting-started-with-the-
pico/2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-25 Thread rbowman via Python-list
On Fri, 23 Aug 2024 16:23:42 +1200, dn wrote:

> Adding a display to the Pico-W is my next project... After that, gyros
> (am thinking it may not go so well, on balance... hah!).

https://toptechboy.com/two-axis-tilt-meter-displaying-pitch-and-roll-
using-an-mpu6050-on-the-raspberry-pi-pico-w/

You might have to go back a lesson or two for the lead up. As he generally 
says in the intro most of what he uses is from the Sunfounder Kepler kit. 
It has a standard LCD display but he suggested buying the OLED separately 
and used it for Lissajous patterns and other fancier stuff.

It's not a bad series although he can be long-winded and his Python style 
definitely isn't PEP8 friendly. 

https://toptechboy.com/

He switched to the Arduino Uno R4 after the IR controller/NeoPixel Pico 
project and I don't know if he intends to go back to the Pico. He uses 
Thonny but I use the MicroPython extension in VS Code. Lately I've been 
using Code for everything. Mostly I work on Linux boxes but it's all the 
same on Windows. There is a PlatformIO extension that works with Arduino 
and other boards. PyLance upsets some because it's a MS product but it 
works well too.  I've used PyCharm and like it but I also work on C, .NET, 
Angular, and other projects and Code gives me a uniform IDE.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-26 Thread rbowman via Python-list
On Sun, 25 Aug 2024 21:29:30 -0400, avi.e.gross wrote:

> If everyone will pardon my curiosity, who and what purposes are these
> smaller environments for and do many people use them?
> 
> I mean the price of a typical minimal laptop is not a big deal today. So
> are these for some sort of embedded uses?
> 
> I read about them ages ago but wonder ...

Typically they are used for I/O with the physical world. Some, like the 
Arduino Nano Sense, have a number of sensors on the board including a 9 
axis inertial, temperature, humidity, barometric, microphone, light 
intensity, and color sensors. MIT chose this for their TinyML course 
because it was one-stop shopping. Using TinyML, a really cut down version 
of TensorFlow, gesture, wake word, image recognition, and other tasks were 
move entirely to the edge device.

Others, like the Pico series, bring out the I/O pins but have little 
onboard. Many pins are multi-purpose and are used for SPI or I2C 
protocols, PWM, A/D measurements, and plain vanilla digital.

The Raspberry Pi series lives in both worlds. Particularly with the new Pi 
5, it's usable as a desktop Linux system, if somewhat limited, while 
bringing out the PIO pins. 

It's really a different world than a typical laptop. Years (decades?) ago 
you could subvert the parallel port controller to provide digital I/O but 
who has seen a parallel port lately? 

There are many families and devices available that are used for any number 
of projects that need to interact with the real world. The earliest 
variants were usually programmed in assembler since 2k of EPROM and 128 
bytes of RAM was typical.  As they improved C was sued. Now there's enough 
flash and SRAM to support MicroPython or CircuitPython and they are fast 
enough for most purposes. There are specialized drivers but if you know 
Python the bulk of the logic will be very familiar. 

For example I have a desktop Python app that pulls weather data from 
NOAA's web API.  The Pico W has Wifi, so if I wanted to compare NOAA's 
temperature, humidity, and barometric pressure to the values I read from a 
local sensor, the API requests and parsing the JSON reply would be almost 
identical to the desktop code.  Conversely I could use the Pico W as a web 
server to make its sensor reading available. 

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


Re: Triggered By Mediocre Code (Posting On Python-List Prohibited)

2024-08-26 Thread rbowman via Python-list
On Sun, 25 Aug 2024 23:49:48 - (UTC), Lawrence D'Oliveiro wrote:

> The irony of my putdown is that PHP can do it about as simply. But don’t
> expect your typical PHP programmers to know that ...

It has had amazing longevity for something that was born as Personal Home 
Page. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new here

2024-08-28 Thread rbowman via Python-list
On Wed, 28 Aug 2024 08:41:28 +0100, Daniel wrote:

> That is so cool. I've had the same idea to use the API with AWS for my
> bbs. I also want to do the same thing for other government sites like
> ecfr for pulling aviation regulations.
> 
> Is your code somewhere I can look at it?

The NOAA?  I didn't get dncy so I'm calling get_station_info with a 
hardcoded latitude and longitude.  The commented out print(json.dumps()) 
pretty print the JSON so you can decide what to extract. I'm not 100% sure 
about tacking K onto the grid ID. The famous 'works for me' A URL like

https://forecast.weather.gov/MapClick.php?lat=40.8551337&lon=-114.0140115

will show the same info, in this case for Wendover Airport (KENV).

https://www.weather.gov/documentation/services-web-api

is the documentation for the API. 

import json
import requests

def get_station_info(latitude, longitude):
url = f"https://api.weather.gov/points/{latitude},{longitude}";
response = requests.get(url).json()
#print(json.dumps(response, indent=4, sort_keys=True))
property = response['properties']
grid_id = property["gridId"]
grid_x = property["gridX"]
grid_y = property["gridY"]
forecast_url = property["forecast"]
observation_url = f"https://api.weather.gov/stations/K{grid_id}/
observations/latest"
response = requests.get(observation_url).json()
#   print(json.dumps(response, indent=4, sort_keys=True))
properties = response['properties']
pressure = properties['barometricPressure']
temperature = properties['temperature']
humidity = properties['relativeHumidity']
dewpoint = properties['dewpoint']

temp = 9 * temperature['value'] / 5 + 32
dew = 9 * dewpoint['value'] / 5 + 32
hum = humidity['value']
bp = pressure['value'] * 0.000295
print(f"temperature {temp} dewpoint {dew:.2f} humidity  {hum:.2f}  
pressure {bp:.2f}\n")

response = requests.get(forecast_url).json()
properties = response['properties']
periods = properties['periods']
#print(json.dumps(period, indent=4, sort_keys=True))
for i in range(0, len(periods)):
period = periods[i]
print(period['name'])
print(period['detailedForecast'])
print(f"temperature: {period['temperature']}")
print(f"wind {period['windSpeed']}  {period['windDirection']}")
print()

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


Re: Script stops running with no error

2024-08-28 Thread rbowman via Python-list
On Wed, 28 Aug 2024 22:09:56 +0100, Daniel wrote:

> if definition:
> print(f"\n{word_type.capitalize()}\n")
> print("\n".join(definition))
> break

I don't know if that was intended but the 'break' kicks you out of 

for word_type, pattern in cases.items():

I added a little debugging to show the cases iteration and commented out 
the break.  'noun' has five lines and appears to be correct. 'verb' has 
two lines, neither of which match the if/else.  The others aren't in the 
return from  https://api.wikimedia.org/core/v1/wiktionary/en/page/table. 

I have to admit I sometimes miss C where I can bounce between curlies.

Output:

python wiki.py

*** Definition for table ***

word_type noun   pattern:  \{en-noun\}(.*?)(?=\{|\Z)
line }
line # Furniture with a top surface to accommodate a variety of uses.
line ## An item of [[furniture]] with a [[flat]] [[top]] [[surface]] 
raised above the ground, usually on one or more legs.
line ##: ''Set that dish on the '''table''' over there, please.''
line ##*

Noun

1. Furniture with a top surface to accommodate a variety of uses.
   a. An item of furniture with a flat top surface raised above the 
ground, usually on one or more legs.

word_type verb   pattern:  \{en-verb\}(.*?)(?=\{|\Z)
line }
line #

word_type adjective   pattern:  \{en-adj\}(.*?)(?=\{|\Z)

word_type adverb   pattern:  \{en-adv\}(.*?)(?=\{|\Z)

word_type preposition   pattern:  \{en-prep\}(.*?)(?=\{|\Z)

word_type conjunction   pattern:  \{en-con\}(.*?)(?=\{|\Z)

word_type interjection   pattern:  \{en-intj\}(.*?)(?=\{|\Z)

word_type determiner   pattern:  \{en-det\}(.*?)(?=\{|\Z)

word_type pronoun   pattern:  \{en-pron\}(.*?)(?=\{|\Z)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old matplotlib animation now fails

2024-10-18 Thread rbowman via Python-list
On Wed, 16 Oct 2024 23:30:42 +0100, Chris Townley wrote:

> Not sure about America, but the bee's knees is still in common use in
> the UK

https://en.wikipedia.org/wiki/Bee's_knees

That version? A local bakery makes a honey flavored pastry they call 
'bee's knees' but using it in a conversation would be campy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old matplotlib animation now fails

2024-10-16 Thread rbowman via Python-list
On 16 Oct 2024 08:20:10 GMT, Martin Schöön wrote:

> Den 2024-10-15 skrev Stefan Ram :
>> Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=  wrote or
>> quoted:
>>>l.set_data(x0, y0)
>>
>>   Well, I got to say, it's pretty rad that you're rocking Python!
>>   That language is the bee's knees, for real.
>>
>>   As for your question, here's my two cents off the cuff:
>>   Could it be that the newer Matplotlib versions are jonesing for
>>   something like "l.set_data( [ x0 ],[ y0 ])" in that spot?
>>
> Thanks, that was quick and adding square brackets fixed my code.
> 
> Me rocking Python?
> 
> /Martin

You have to understand Stefan tries to use American slang, not always 
entirely accurately. I think 'bee's knees' died out around 1931.

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


Re: learning Python

2024-10-29 Thread rbowman via Python-list
On Tue, 29 Oct 2024 16:05:53 -0600, Mats Wichmann wrote:

> Frankly, the mountain of resources is so vast that none of us can have
> experience of more than a small fraction, and effective learning is a
> factor not only of the quality of the teacher/book/training course, but
> how it meshes with your own learning style.

It isn't a beginners tutorial but at some point 'Python Distilled' is 
helpful.

https://www.dabeaz.com/python-distilled/

Usual disclaimer: i don't know Beazley and am not getting any kickback.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pip installs to unexpected place

2025-04-14 Thread rbowman via Python-list
On Mon, 14 Apr 2025 09:55:09 -0400, Thomas Passin wrote:

> Pip doesn't know about the environment it runs in. It seems to me that
> you didn't active the venv before you installed using pip. So nothing
> would have gotten installed into the venv. So where is the venv that you
> set up? I usually put them into ~/venv. For example, a venv named "gf4"
> is at ~/venv/gf4.

Are you sure about that? activate has


VIRTUAL_ENV="/home/rbowman/work/python/weather"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

$PATH is modified to point to the bin directory in the venv, and it 
includes python and pip. You can use 'python3' if you really want to since 
it is there also. 

$ which pip
/home/rbowman/work/python/weather/bin/pip

'deactivate'  restores $PATH.  

I'll agree it sounds like the venv wasn't activated. 



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


Re: Pip installs to unexpected place

2025-04-14 Thread rbowman via Python-list
On Sun, 13 Apr 2025 19:10:47 -0400, Jonathan Gossage wrote:

> The version of Python was compiled from source code and installed with
> make altinstall. I attempted to use *pip* to install the *Sphinx*
> package into the virtual environment using the command *pip install
> sphinx* in the virtual environment*.

How did you create the venv? Was it activated? I would use 'python -m pip 
install sphinx' but a bare pip should work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pip installs to unexpected place

2025-04-16 Thread rbowman via Python-list
On Tue, 15 Apr 2025 14:12:19 -0400, Thomas Passin wrote:

> On Linux, at least, it's standard for pip to install into the user's
> site-packages location if it's not invoked with admin privileges - even
> without --user. Pip will emit a message saying so. Well, that used to be
> true but nowadays Pip wants you to use the --break-system-packages flag
> if you want to insist on installing into the system's Python install,
> even if it's going to go into --user. I'm not sure if the restriction
> will be in place given that the OP built his own Python version.

Is that pip or a distro's version of pip? On Fedora I get the message 
about defaulting to user. On Ubuntu I get a message to use a venv or if I 
really want a global install to use something like 'pip install python3-
black'. Ubuntu's is pip 24.2, Fedor's is 24.3.1 but neither of them show 
'--break-system-packages' in --help.



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


Re: Pip installs to unexpected place

2025-04-15 Thread rbowman via Python-list
On Mon, 14 Apr 2025 15:20:13 -0700, Keith Thompson wrote:

> Making the active script executable introdues the risk that you'll
> accidentally execute it rather than sourcing it.  If you do that, it
> will probably set up the environment in a new shell process which then
> immediately terminates.

The 'activate' script starts with

# This file must be used with "source bin/activate" *from bash*
# You cannot run it directly

The csh and fish variants have similar warnings. I don't have a Windows 
box up at the moment but iirc  activate.bat or Activate.ps1 is in the 
Scripts subdirectory and you do run it directly. On Linux the python in 
bin is usually a symlink, although you can specify it to be copied with a 
parameter to venv.  Symlinks on Windows are problematic but the process is 
more or less the same.





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


Re: Pip installs to unexpected place

2025-04-15 Thread rbowman via Python-list
On Tue, 15 Apr 2025 18:43:43 +0200, Friedrich Romstedt wrote:

> Many people put emphasis on that you need to *activate* a virtualenv
> before using it, but no-one so far stressed the fact that you got Sphinx
> installed to ~/jonathan/.local/lib/python3.13/site-packages *without
> using *--user.

This may depend on the OS. On Ubuntu 24.10  with python 3.12.7 I get

$ pip install black
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
   If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

I do have '/home/rbowman/.local/lib/python3.10/site-packages' left over 
from earlier versions of Ubuntu.


However on Fedora 42 with 3.13.2

Defaulting to user installation because normal site-packages is not 
writable. 







 

-- 
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


Re: Book recommendation? For getting up to date

2025-02-16 Thread rbowman via Python-list
On Sun, 16 Feb 2025 22:00:11 +0100, Jan Erik Moström wrote:

> I have done so ... to be really honest, it was when I couldn't remember
> how to create an iterator for a class I was writing, that I realized
> that I needed a refresher.

Most of my Python was related to Esri's ArcGIS version. Up until a few 
years ago installing their product would install Python 2.7. With Esri 11, 
they moved to Python 3. Modifying my scripts wasn't difficult but I 
thought I should expand my Python knowledge. There were quite a few 
features like list comprehensions I'd never used. I also appreciated f 
strings when they were introduced, the walrus operator, and other 
enhancements.

Another part of my renewed interest was the advent of many 
microcontrollers capable of running MicroPython, which is a subset of 
Python 3.x.

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


Re: Book recommendation? For getting up to date

2025-02-16 Thread rbowman via Python-list
On Mon, 17 Feb 2025 08:59:11 +1300, dn wrote:

> - on Coursera am sad to advise avoiding U.Mich courses - they tend to be
> re-worded Java (I think) content, don't follow PEP-008 and 'miss' Python
> idioms

The edx CS50 Python from Harvard is decent. It does start with the basics 
but overall I enjoyed it. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Book recommendation? For getting up to date

2025-02-16 Thread rbowman via Python-list
On Sun, 16 Feb 2025 13:50:33 +0100, Jan Erik Moström wrote:

> I used to be fairly good at Python, but I haven't done any serious
> programming in the last 10 years or so. So I would like something that
> got me up-to-date with the latest features.

David Beasley's 'Python Distilled'. The author doesn't enumerate Python 3 
features specifically but as the title suggests hits the important 
concepts. 

https://www.dabeaz.com/python-distilled/

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


Re: Book recommendation? For getting up to date (Posting On Python-List Prohibited)

2025-02-21 Thread rbowman via Python-list
On Thu, 20 Feb 2025 21:51:51 - (UTC), Lawrence D'Oliveiro wrote:

> On Thu, 20 Feb 2025 10:05:32 -0300, Salvador Mirzo wrote:
> 
>> It's much more pleasurable (to me) to read books off-screen.
> 
> You can’t do searches, though.

For non-fiction a decent index does wonders. A good layout and talble of 
contents also helps. Decorators? Chapter 14, page 254, all you ever wanted 
to know about them. 
-- 
https://mail.python.org/mailman/listinfo/python-list