From rosuav at gmail.com Fri Jul 2 05:44:34 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 2 Jul 2021 19:44:34 +1000 Subject: Unfindable module: code Message-ID: I've just spent half an hour trying to figure out how to mess with the Python REPL (specifically, how to implement a line-by-line interactive interpreter within a larger app). It's rather hard to find it, but the key module is "code". https://docs.python.org/3/library/code.html (How did I end up finding it? By searching the CPython source code for "ps1", since interactive mode looks at sys.ps1/sys.ps2 for its prompts.) In the module index, it is listed thus: Custom Python Interpreters * code ? Interpreter base classes * codeop ? Compile Python code While this isn't *wrong*, per se, it does hide the fact that this is where the REPL can be found. IMO it would be helpful to say that in the summary, but I'm not sure what would be good wording. What do people think of calling it "Interactive interpreter and REPL implementation"? ChrisA From jorge.conforte at inpe.br Fri Jul 2 08:23:46 2021 From: jorge.conforte at inpe.br (Jorge Conforte) Date: Fri, 2 Jul 2021 09:23:46 -0300 Subject: Xarray smoothing data Message-ID: Hi, I'm using xarray to read and plot my netcdf data. Please someone could help me, dow can I smooth my data before to plot i. Thanks, Conrado From __peter__ at web.de Fri Jul 2 09:00:05 2021 From: __peter__ at web.de (Peter Otten) Date: Fri, 2 Jul 2021 15:00:05 +0200 Subject: Unfindable module: code In-Reply-To: References: Message-ID: On 02/07/2021 11:44, Chris Angelico wrote: > I've just spent half an hour trying to figure out how to mess with the > Python REPL (specifically, how to implement a line-by-line interactive > interpreter within a larger app). It's rather hard to find it, but the > key module is "code". > > https://docs.python.org/3/library/code.html > > (How did I end up finding it? By searching the CPython source code for > "ps1", since interactive mode looks at sys.ps1/sys.ps2 for its > prompts.) I would probably have done that too, but for "interpreter". However, googling for "python interactive interpreter module" has the code documentation as its second hit and https://docs.python.org/3/library/custominterp.html as its third. > In the module index, it is listed thus: > > Custom Python Interpreters > * code ? Interpreter base classes > * codeop ? Compile Python code > > While this isn't *wrong*, per se, it does hide the fact that this is > where the REPL can be found. IMO it would be helpful to say that in > the summary, but I'm not sure what would be good wording. > > What do people think of calling it "Interactive interpreter and REPL > implementation"? To be honest, I think the "unfindable" part are the module names; I don't see a big difference between your suggested and the current description. From rosuav at gmail.com Fri Jul 2 09:04:55 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 2 Jul 2021 23:04:55 +1000 Subject: Unfindable module: code In-Reply-To: References: Message-ID: On Fri, Jul 2, 2021 at 11:01 PM Peter Otten <__peter__ at web.de> wrote: > > On 02/07/2021 11:44, Chris Angelico wrote: > > I've just spent half an hour trying to figure out how to mess with the > > Python REPL (specifically, how to implement a line-by-line interactive > > interpreter within a larger app). It's rather hard to find it, but the > > key module is "code". > > > > https://docs.python.org/3/library/code.html > > > > (How did I end up finding it? By searching the CPython source code for > > "ps1", since interactive mode looks at sys.ps1/sys.ps2 for its > > prompts.) > > I would probably have done that too, but for "interpreter". Fair enough, but "interpreter" comes up in a lot of contexts. > However, googling for "python interactive interpreter module" has the > code documentation as its second hit and > > https://docs.python.org/3/library/custominterp.html > > as its third. Good point. Unfortunately, "python repl module" mainly has hits for the "cmd" module, which is quite different. I don't understand this, actually. Strange results. Part of the problem was that I didn't know for sure that I was looking for a *module* per se, and trying to find anything about "python interactive interpreter" will of course just give results about how to invoke Python without an argument, or with "-i script.py". > > In the module index, it is listed thus: > > > > Custom Python Interpreters > > * code ? Interpreter base classes > > * codeop ? Compile Python code > > > > While this isn't *wrong*, per se, it does hide the fact that this is > > where the REPL can be found. IMO it would be helpful to say that in > > the summary, but I'm not sure what would be good wording. > > > > What do people think of calling it "Interactive interpreter and REPL > > implementation"? > > To be honest, I think the "unfindable" part are the module names; I > don't see a big difference between your suggested and the current > description. > Fair enough! Just wondered. ChrisA From nikitalohale01 at gmail.com Fri Jul 2 02:53:10 2021 From: nikitalohale01 at gmail.com (Nikita Lohale) Date: Thu, 1 Jul 2021 23:53:10 -0700 (PDT) Subject: pyttsx3 installation error Message-ID: <0be83a52-ba96-4e1e-a8f9-b4ef659123fcn@googlegroups.com> Traceback (most recent call last): File "f:\Nikita\Python programming\Iron Man Jarvis AL\jarvis.py", line 1, in import pyttsx3 ModuleNotFoundError: No module named 'pyttsx3' From abhi.darkness at gmail.com Fri Jul 2 16:56:24 2021 From: abhi.darkness at gmail.com (Abhiram R) Date: Sat, 3 Jul 2021 02:26:24 +0530 Subject: pyttsx3 installation error In-Reply-To: <0be83a52-ba96-4e1e-a8f9-b4ef659123fcn@googlegroups.com> References: <0be83a52-ba96-4e1e-a8f9-b4ef659123fcn@googlegroups.com> Message-ID: Congratulations on trying out something new in Python. The first step to debugging errors is try and Google them. Unless it's a brand new package, chances are, you'll find a solution there almost immediately. In case you've already installed this missing package, and it's not getting imported, I'd suggest reading up on Virtual environments, how to create one, how to activate one and how to install packages in them. These might seem tedious if you're just starting off, but it's going to pay off. Happy programming! Abhiram R abhiramr.com On Sat, Jul 3, 2021, 2:13 AM Nikita Lohale wrote: > Traceback (most recent call last): > File "f:\Nikita\Python programming\Iron Man Jarvis AL\jarvis.py", line > 1, in > import pyttsx3 > ModuleNotFoundError: No module named 'pyttsx3' > -- > https://mail.python.org/mailman/listinfo/python-list > From roland.em0001 at googlemail.com Fri Jul 2 16:57:08 2021 From: roland.em0001 at googlemail.com (Roland Mueller) Date: Fri, 2 Jul 2021 23:57:08 +0300 Subject: pyttsx3 installation error In-Reply-To: <0be83a52-ba96-4e1e-a8f9-b4ef659123fcn@googlegroups.com> References: <0be83a52-ba96-4e1e-a8f9-b4ef659123fcn@googlegroups.com> Message-ID: What's about installing? https://pypi.org/project/pyttsx3/ pe 2. hein?k. 2021 klo 23.41 Nikita Lohale (nikitalohale01 at gmail.com) kirjoitti: > Traceback (most recent call last): > File "f:\Nikita\Python programming\Iron Man Jarvis AL\jarvis.py", line > 1, in > import pyttsx3 > ModuleNotFoundError: No module named 'pyttsx3' > -- > https://mail.python.org/mailman/listinfo/python-list > From phoenix1987 at gmail.com Fri Jul 2 19:04:24 2021 From: phoenix1987 at gmail.com (Gabriele Tornetta) Date: Fri, 2 Jul 2021 16:04:24 -0700 (PDT) Subject: [ANN] Austin -- CPython frame stack sampler v3.0.0 is now available Message-ID: <0b92d190-5c65-4c1a-a15d-be0c8dc384ffn@googlegroups.com> I am delighted to announce the release 3.0.0 of Austin. If you haven't heard of Austin before, it is an open-source frame stack sampler for CPython, distributed under the GPLv3 license. It can be used to obtain statistical profiling data out of a running Python application without a single line of instrumentation. This means that you can start profiling a Python application straight away, even while it's running in a production environment, with minimal impact on performance. The best way to leverage Austin is to use the new extension for VS Code, which brings interactive flame graphs straight into the text editor to allow you to quickly jump to the source code with a simple click. You can find the extension on the Visual Studio Marketplace and install it directly from VS Code: https://marketplace.visualstudio.com/items?itemName=p403n1x87.austin-vscode To see how to make the best of Austin with VS Code to find and fix performance issues, check out this blog post, which shows you the editor extension in action on a real Python project: https://p403n1x87.github.io/how-to-bust-python-performance-issues.html The latest release comes with many improvements, including a re-worked sleepless mode that now gives an estimate of CPU time, initial support for Python 3.10, better support for Python-based binaries like gunicorn, uWSGI, etc. on all supported platforms. Austin is a pure C application that has no dependencies other than the C standard library. Its source code is hosted on GitHub at https://github.com/P403n1x87/austin The README contains installation and usage details, as well as some examples of Austin in action. Details on how to contribute to Austin's development can be found at the bottom of the page. Austin can be installed easily on the following platforms and from the following sources: Linux: - Snap Store - Debian repositories macOS: - Homebrew Windows: - Chocolatey - Scoop An Austin image, based on Ubuntu 20.04, is also available from Docker Hub: https://hub.docker.com/r/p403n1x87/austin Austin is also simple to compile from sources as it only depends on the standard C library if you don't have access to the above-listed sources. You can stay up-to-date with the project's development by following Austin on Twitter (https://twitter.com/AustinSampler). All the best, Gabriele From martinp.dipaola at gmail.com Fri Jul 2 20:55:33 2021 From: martinp.dipaola at gmail.com (Martin Di Paola) Date: Sat, 3 Jul 2021 00:55:33 +0000 Subject: [ANN] Austin -- CPython frame stack sampler v3.0.0 is now available In-Reply-To: <0b92d190-5c65-4c1a-a15d-be0c8dc384ffn@googlegroups.com> References: <0b92d190-5c65-4c1a-a15d-be0c8dc384ffn@googlegroups.com> Message-ID: <20210703005533.er7hbpwani2bgs64@gmail.com> Very nice. I used rbspy for Ruby programs https://rbspy.github.io/ and it can give you some insights about the running code that other profiling techniques may not give you. I'll use it in my next performance-bottleneck challenge. On Fri, Jul 02, 2021 at 04:04:24PM -0700, Gabriele Tornetta wrote: >I am delighted to announce the release 3.0.0 of Austin. If you haven't heard of Austin before, it is an open-source frame stack sampler for CPython, distributed under the GPLv3 license. It can be used to obtain statistical profiling data out of a running Python application without a single line of instrumentation. This means that you can start profiling a Python application straight away, even while it's running in a production environment, with minimal impact on performance. > >The best way to leverage Austin is to use the new extension for VS Code, which brings interactive flame graphs straight into the text editor to allow you to quickly jump to the source code with a simple click. You can find the extension on the Visual Studio Marketplace and install it directly from VS Code: > >https://marketplace.visualstudio.com/items?itemName=p403n1x87.austin-vscode > >To see how to make the best of Austin with VS Code to find and fix performance issues, check out this blog post, which shows you the editor extension in action on a real Python project: > >https://p403n1x87.github.io/how-to-bust-python-performance-issues.html > >The latest release comes with many improvements, including a re-worked sleepless mode that now gives an estimate of CPU time, initial support for Python 3.10, better support for Python-based binaries like gunicorn, uWSGI, etc. on all supported platforms. > >Austin is a pure C application that has no dependencies other than the C standard library. Its source code is hosted on GitHub at > >https://github.com/P403n1x87/austin > >The README contains installation and usage details, as well as some examples of Austin in action. Details on how to contribute to Austin's development can be found at the bottom of the page. > >Austin can be installed easily on the following platforms and from the following sources: > >Linux: >- Snap Store >- Debian repositories > >macOS: >- Homebrew > >Windows: >- Chocolatey >- Scoop > >An Austin image, based on Ubuntu 20.04, is also available from Docker Hub: > >https://hub.docker.com/r/p403n1x87/austin > >Austin is also simple to compile from sources as it only depends on the standard C library if you don't have access to the above-listed sources. > > >You can stay up-to-date with the project's development by following Austin on Twitter (https://twitter.com/AustinSampler). > >All the best, >Gabriele >-- >https://mail.python.org/mailman/listinfo/python-list From tjreedy at udel.edu Sat Jul 3 03:35:51 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 3 Jul 2021 03:35:51 -0400 Subject: Unfindable module: code In-Reply-To: References: Message-ID: On 7/2/2021 5:44 AM, Chris Angelico wrote: > I've just spent half an hour trying to figure out how to mess with the > Python REPL (specifically, how to implement a line-by-line interactive > interpreter within a larger app). It's rather hard to find it, but the > key module is "code". > > https://docs.python.org/3/library/code.html > > (How did I end up finding it? By searching the CPython source code for > "ps1", since interactive mode looks at sys.ps1/sys.ps2 for its > prompts.) > > In the module index, it is listed thus: > > Custom Python Interpreters > * code ? Interpreter base classes > * codeop ? Compile Python code > > While this isn't *wrong*, per se, it does hide the fact that this is > where the REPL can be found. IMO it would be helpful to say that in > the summary, but I'm not sure what would be good wording. > > What do people think of calling it "Interactive interpreter I think that would be better. The module include an console function, so it can be used as is. ? and REPL implementation"? Nah. I believe codeop is only for interactive code. -- Terry Jan Reedy From mal at europython.eu Tue Jul 6 05:04:05 2021 From: mal at europython.eu (Marc-Andre Lemburg) Date: Tue, 6 Jul 2021 11:04:05 +0200 Subject: EuroPython 2021: Trainings and Workshops Message-ID: Have you ever wanted to build an image search system, take a deep dive into pytest or learn about algorithmic trading? Then we have a treat for you! The EuroPython conference will start with two full training and workshop days on Monday, July 26th, and Tuesday, July 27th: * EuroPython Trainings and Workshops * https://ep2021.europython.eu/events/trainings/ Combined Ticket Training sessions --------------------------------- We have carefully curated 14 paid training sessions, which you can attend with a Combined Ticket. Each session is 3 hours long. - Build a deep learning-powered image search system with Jina + BigTransfer (BiT) - Building a practical Slack bot with Python & FastAPI - Climate data analysis with xarray and cartopy - Creating 2D Applications and Games - Data Analysis with pandas - Workshop - Docker for Machine Learning Engineers - GPU development with Python 101 - Implementing a Neural Network from Scratch - Introduction to Property-Based Testing - Introduction to pytest - Speedrunning Web Development: A Full Stack App in 10 minutes - The Anatomy of a Python Class - Transcend the realms of development - A day in life of a software architect - Understanding Decorators and Context Managers If you already have a conference ticket, but would like to switch to a combined ticket, please email helpdesk at europython.eu. You will receive a discount coupon that allows you to upgrade your ticket to a combined one. Conference Ticket Training Sessions ----------------------------------- Additionally, if you have purchased a Conference only Ticket, you are welcome to join the 4 sponsored workshops in the Argument-Clinic track! - Activate Your Interest in Coding for Algorithmic Trading - Build and deploy PyTorch models with Azure Machine Learning - Knowledge graph data modelling with TerminusDB - Python Packaging Demystified Special Workshops ----------------- For total beginners, we have teamed up with Humble Data to deliver a Beginners' Day Workshop, specifically for newcomers to Python. This is also accessible for Conference only Ticket holders and is scheduled for Tuesday. We are also working on a Django Girls Workshop, which will be announced separately. We?ve scheduled this for Monday. Quick Summary ------------- EuroPython 2021 will be run online from July 26 - August 1: - Two workshop/training days (July 26 - 27) - Three conference days (July 28 - 30) - Two sprint days (July 31 - August 1) The sessions will be scheduled to ensure they are also accessible for those in the Asian and Americas time zones. More infos are available on our website at https://ep2021.europython.eu/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-trainings-and-workshops/ Tweet: https://twitter.com/europython/status/1412334539385540608 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ From arakelthedragon at gmail.com Wed Jul 7 05:11:21 2021 From: arakelthedragon at gmail.com (Arak Rachael) Date: Wed, 7 Jul 2021 02:11:21 -0700 (PDT) Subject: Help with gaussian filter from scipy Message-ID: Hi guys, thanks for the help in the past, this time I am stuck on gaussian_filter scipy returns none instead of some valid gaussian filtered image, can someone help me please. Here is the full code: https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 From ben.usenet at bsb.me.uk Wed Jul 7 06:41:25 2021 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Wed, 07 Jul 2021 11:41:25 +0100 Subject: Help with gaussian filter from scipy References: Message-ID: <87o8be76ei.fsf@bsb.me.uk> Arak Rachael writes: > this time I am stuck on gaussian_filter scipy returns none instead of some valid gaussian filtered image, can someone help me please. > > Here is the full code: > https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 It might help to link to the code itself so people can look at it without having to load up a project. -- Ben. From arakelthedragon at gmail.com Wed Jul 7 06:47:29 2021 From: arakelthedragon at gmail.com (Arak Rachael) Date: Wed, 7 Jul 2021 03:47:29 -0700 (PDT) Subject: Help with gaussian filter from scipy In-Reply-To: <87o8be76ei.fsf@bsb.me.uk> References: <87o8be76ei.fsf@bsb.me.uk> Message-ID: <04d6f01b-585e-4aa8-9bb9-1f519c9e9360n@googlegroups.com> On Wednesday, 7 July 2021 at 12:41:44 UTC+2, Ben Bacarisse wrote: > Arak Rachael writes: > > > this time I am stuck on gaussian_filter scipy returns none instead of some valid gaussian filtered image, can someone help me please. > > > > Here is the full code: > > https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 > It might help to link to the code itself so people can look at it > without having to load up a project. > > -- > Ben. Sorry I don't have this option. I loaded it in PyCharm and this is what I got: /home/yordan/anaconda3/envs/testing/bin/python /home/yordan/pycharm/plugins/python-ce/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 36321 --file /home/yordan/devel/python.assignments/topgis-viz/topgisviz/xdog.py Connected to pydev debugger (build 211.7442.45) Usage: python xdog.py FILE OUTPUT I tried creating "'./textures/hatch.jpg" image, but it did not work. From arakelthedragon at gmail.com Wed Jul 7 08:02:27 2021 From: arakelthedragon at gmail.com (Arak Rachael) Date: Wed, 7 Jul 2021 05:02:27 -0700 (PDT) Subject: Help with gaussian filter from scipy In-Reply-To: <04d6f01b-585e-4aa8-9bb9-1f519c9e9360n@googlegroups.com> References: <87o8be76ei.fsf@bsb.me.uk> <04d6f01b-585e-4aa8-9bb9-1f519c9e9360n@googlegroups.com> Message-ID: On Wednesday, 7 July 2021 at 12:47:40 UTC+2, Arak Rachael wrote: > On Wednesday, 7 July 2021 at 12:41:44 UTC+2, Ben Bacarisse wrote: > > Arak Rachael writes: > > > > > this time I am stuck on gaussian_filter scipy returns none instead of some valid gaussian filtered image, can someone help me please. > > > > > > Here is the full code: > > > https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 > > It might help to link to the code itself so people can look at it > > without having to load up a project. > > > > -- > > Ben. > Sorry I don't have this option. > > I loaded it in PyCharm and this is what I got: > > /home/yordan/anaconda3/envs/testing/bin/python /home/yordan/pycharm/plugins/python-ce/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 36321 --file /home/yordan/devel/python.assignments/topgis-viz/topgisviz/xdog.py > Connected to pydev debugger (build 211.7442.45) > Usage: python xdog.py FILE OUTPUT > > I tried creating "'./textures/hatch.jpg" image, but it did not work. Sorry for taking your time, this turns to be a dum question, I needed to supply in file and out file in the command line. From ben.usenet at bsb.me.uk Wed Jul 7 10:23:31 2021 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Wed, 07 Jul 2021 15:23:31 +0100 Subject: Help with gaussian filter from scipy References: <87o8be76ei.fsf@bsb.me.uk> <04d6f01b-585e-4aa8-9bb9-1f519c9e9360n@googlegroups.com> Message-ID: <87czru6w4c.fsf@bsb.me.uk> Arak Rachael writes: > On Wednesday, 7 July 2021 at 12:47:40 UTC+2, Arak Rachael wrote: >> On Wednesday, 7 July 2021 at 12:41:44 UTC+2, Ben Bacarisse wrote: >> > Arak Rachael writes: >> > >> > > this time I am stuck on gaussian_filter scipy returns none instead of some valid gaussian filtered image, can someone help me please. >> > > >> > > Here is the full code: >> > > https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 >> > It might help to link to the code itself so people can look at it >> > without having to load up a project. >> > >> > -- >> > Ben. >> Sorry I don't have this option. >> >> I loaded it in PyCharm and this is what I got: >> >> /home/yordan/anaconda3/envs/testing/bin/python /home/yordan/pycharm/plugins/python-ce/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 36321 --file /home/yordan/devel/python.assignments/topgis-viz/topgisviz/xdog.py >> Connected to pydev debugger (build 211.7442.45) >> Usage: python xdog.py FILE OUTPUT >> >> I tried creating "'./textures/hatch.jpg" image, but it did not work. > > Sorry for taking your time, this turns to be a dum question, I needed > to supply in file and out file in the command line. No worries. Sometimes just posting the question make you look at it differently. If you can post code, it's much better to do that. Had it been a little bit more obscure a problem, someone might have spotted it but they may not have wanted to load a project file. -- Ben. From mal at europython.eu Thu Jul 8 05:11:51 2021 From: mal at europython.eu (Marc-Andre Lemburg) Date: Thu, 8 Jul 2021 11:11:51 +0200 Subject: EuroPython 2021: Opening our Merchandise Shop Message-ID: <8273870c-9eea-8a31-ddc9-a6b911f68aa1@europython.eu> We?re very happy to announce our merchandise shop for EuroPython 2021, with a fabulous new design for the attendee t-shirts: * EuroPython 2021 Merch Shop * https://ep2021.europython.eu/europython/europython-merchandise-shop/ You can find the shop under the "EuroPython" menu entry on the conference website. It is run on the Spreadshirt platform and so Spreadshirt will handle all payments, invoicing and shipping. We have preconfigured a large number of items in the shop based on the designs for EuroPython 2021, but you can also customize the looks by clicking on the editing pen on the product pages. Any profit this creates will go towards the EuroPython financial aid budget, so will be put to good use. Discounts --------- To make things a little easier for you, we have configured the following discounts Spreadshirt offers: - 20% off from July 8 - 11 - 15% off from July 12 - 15 - free shipping from July 16 - 19 Shipping worldwide ------------------ Spreadshirt is shipping to a lot of destinations worldwide. Unfortunately, they don?t support shipping to the US, Australia, Brasil and a few other countries on their European shop system for tax reasons. If you'd like to order from one of those countries, perhaps you can find a friendly Pythonista who would be willing to forward you the merch from Europe. Quick Summary ------------- EuroPython 2021 will be run online from July 26 - August 1: - Two workshop/training days (July 26 - 27) - Three conference days (July 28 - 30) - Two sprint days (July 31 - August 1) The sessions will be scheduled to ensure they are also accessible for those in the Asian and Americas time zones. More infos are available on our website at https://ep2021.europython.eu/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-opening-our-merchandise-shop/ Tweet: https://twitter.com/europython/status/1413062098331054083 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ From vergos.nikolas at gmail.com Thu Jul 8 09:42:48 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Thu, 8 Jul 2021 06:42:48 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? Message-ID: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? [nikos at superhost wsgi]$ export FLASK_APP=www.py [nikos at superhost wsgi]$ export FLASK_ENV=development [nikos at superhost wsgi]$ flask run * Serving Flask app 'www.py' (lazy loading) * Environment: development * Debug mode: on Usage: flask run [OPTIONS] Try 'flask run --help' for help. Error: While importing 'www', an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app __import__(module_name) File "/home/nikos/wsgi/www.py", line 4, in import counters File "/home/nikos/wsgi/counters.py", line 6, in from flask import run, route, request, redirect ImportError: cannot import name 'run' and this is the error_log when tries to be displayed via browser: [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): Failed to exec Python script file '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent call last): [Thu Jul 08 15:08:36.436432 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] File "/home/nikos/wsgi/www.py", line 4, in [Thu Jul 08 15:08:36.436436 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] import counters [Thu Jul 08 15:08:36.436441 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] File "/home/nikos/wsgi/counters.py", line 6, in [Thu Jul 08 15:08:36.436444 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] from flask import run, route, request, redirect [Thu Jul 08 15:08:36.436458 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] ImportError: cannot import name 'run' [Thu Jul 08 15:08:40.075655 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): Failed to exec Python script file '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:40.075703 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:40.075785 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] Traceback (most recent call last): [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] File "/home/nikos/wsgi/www.py", line 4, in [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] import counters [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] File "/home/nikos/wsgi/counters.py", line 6, in [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] from flask import run, route, request, redirect [Thu Jul 08 15:08:40.075825 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:13389] ImportError: cannot import name 'run' From vergos.nikolas at gmail.com Thu Jul 8 12:08:21 2021 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Thu, 8 Jul 2021 19:08:21 +0300 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: No, the way i have installed flask was under root account with the command pip3 install flask. But even if i installed flask under my nikos user account its evene worse as the file flask is not entered into PATH. So i guess as root i have to install flask, but then why cant it import 'run" ? [root at superhost ~]# whereis flask flask: /usr/local/bin/flask ???? ???, 8 ???? 2021 ???? 7:02 ?.?., ?/? Stestagg ??????: > Hi > > Do you have a file or folder named 'flask' in the same directory as www.py > by any chance? > > Steve > > On Thu, Jul 8, 2021 at 4:50 PM vergos.... at gmail.com < > vergos.nikolas at gmail.com> wrote: > >> i just moved from bottleframework to flask. I changes what needed to be >> altered to convert the code and when i run it i just get "Internal server >> error" >> >> Running tail -f ../logs/error_log i get no errors. >> >> How can i find out what is the culprit here? >> >> [nikos at superhost wsgi]$ export FLASK_APP=www.py >> [nikos at superhost wsgi]$ export FLASK_ENV=development >> [nikos at superhost wsgi]$ flask run >> * Serving Flask app 'www.py' (lazy loading) >> * Environment: development >> * Debug mode: on >> Usage: flask run [OPTIONS] >> Try 'flask run --help' for help. >> >> Error: While importing 'www', an ImportError was raised: >> >> Traceback (most recent call last): >> File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line >> 256, in locate_app >> __import__(module_name) >> File "/home/nikos/wsgi/www.py", line 4, in >> import counters >> File "/home/nikos/wsgi/counters.py", line 6, in >> from flask import run, route, request, redirect >> ImportError: cannot import name 'run' >> >> and this is the error_log when tries to be displayed via browser: >> >> [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): >> Failed to exec Python script file '/home/nikos/wsgi/www.py'. >> >> [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): >> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. >> >> [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent >> call last): >> >> [Thu Jul 08 15:08:36.436432 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] File >> "/home/nikos/wsgi/www.py", line 4, in >> >> [Thu Jul 08 15:08:36.436436 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] import counters >> >> [Thu Jul 08 15:08:36.436441 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] File >> "/home/nikos/wsgi/counters.py", line 6, in >> >> [Thu Jul 08 15:08:36.436444 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] from flask import run, >> route, request, redirect >> >> [Thu Jul 08 15:08:36.436458 2021] [wsgi:error] [pid 575443:tid >> 139757752112896] [remote 89.210.199.119:6718] ImportError: cannot import >> name 'run' >> >> [Thu Jul 08 15:08:40.075655 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): >> Failed to exec Python script file '/home/nikos/wsgi/www.py'. >> >> [Thu Jul 08 15:08:40.075703 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): >> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. >> >> [Thu Jul 08 15:08:40.075785 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] Traceback (most recent >> call last): >> >> [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] File >> "/home/nikos/wsgi/www.py", line 4, in >> >> [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] import counters >> >> [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] File >> "/home/nikos/wsgi/counters.py", line 6, in >> >> [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] from flask import run, >> route, request, redirect >> >> [Thu Jul 08 15:08:40.075825 2021] [wsgi:error] [pid 575443:tid >> 139757777291008] [remote 89.210.199.119:13389] ImportError: cannot >> import name 'run' >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From stestagg at gmail.com Thu Jul 8 12:02:03 2021 From: stestagg at gmail.com (Stestagg) Date: Thu, 8 Jul 2021 17:02:03 +0100 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? In-Reply-To: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: Hi Do you have a file or folder named 'flask' in the same directory as www.py by any chance? Steve On Thu, Jul 8, 2021 at 4:50 PM vergos.... at gmail.com < vergos.nikolas at gmail.com> wrote: > i just moved from bottleframework to flask. I changes what needed to be > altered to convert the code and when i run it i just get "Internal server > error" > > Running tail -f ../logs/error_log i get no errors. > > How can i find out what is the culprit here? > > [nikos at superhost wsgi]$ export FLASK_APP=www.py > [nikos at superhost wsgi]$ export FLASK_ENV=development > [nikos at superhost wsgi]$ flask run > * Serving Flask app 'www.py' (lazy loading) > * Environment: development > * Debug mode: on > Usage: flask run [OPTIONS] > Try 'flask run --help' for help. > > Error: While importing 'www', an ImportError was raised: > > Traceback (most recent call last): > File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line > 256, in locate_app > __import__(module_name) > File "/home/nikos/wsgi/www.py", line 4, in > import counters > File "/home/nikos/wsgi/counters.py", line 6, in > from flask import run, route, request, redirect > ImportError: cannot import name 'run' > > and this is the error_log when tries to be displayed via browser: > > [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): > Failed to exec Python script file '/home/nikos/wsgi/www.py'. > > [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): > Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. > > [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent call > last): > > [Thu Jul 08 15:08:36.436432 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] File > "/home/nikos/wsgi/www.py", line 4, in > > [Thu Jul 08 15:08:36.436436 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] import counters > > [Thu Jul 08 15:08:36.436441 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] File > "/home/nikos/wsgi/counters.py", line 6, in > > [Thu Jul 08 15:08:36.436444 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] from flask import run, > route, request, redirect > > [Thu Jul 08 15:08:36.436458 2021] [wsgi:error] [pid 575443:tid > 139757752112896] [remote 89.210.199.119:6718] ImportError: cannot import > name 'run' > > [Thu Jul 08 15:08:40.075655 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): > Failed to exec Python script file '/home/nikos/wsgi/www.py'. > > [Thu Jul 08 15:08:40.075703 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): > Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. > > [Thu Jul 08 15:08:40.075785 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] Traceback (most recent > call last): > > [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] File > "/home/nikos/wsgi/www.py", line 4, in > > [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] import counters > > [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] File > "/home/nikos/wsgi/counters.py", line 6, in > > [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] from flask import run, > route, request, redirect > > [Thu Jul 08 15:08:40.075825 2021] [wsgi:error] [pid 575443:tid > 139757777291008] [remote 89.210.199.119:13389] ImportError: cannot import > name 'run' > -- > https://mail.python.org/mailman/listinfo/python-list > From stestagg at gmail.com Thu Jul 8 12:15:56 2021 From: stestagg at gmail.com (Stestagg) Date: Thu, 8 Jul 2021 17:15:56 +0100 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: [my reply on the list this time :)] That's fine. Sorry, I should have provided more information. This type of error that you're gettting /can/ happen if you have the library correctly installed, but within your project, you have a different file of the same name as the library. Then when python tries to import 'flask', it actually imports your local file, NOT the installed flask. You see the error message is *not* saying that python can't find flask, but that it can't find a name `run` within the flask module: from flask import run, route, request, redirect ImportError: cannot import name 'run' Therefore python has successfully found a module named flask somewhere, just that it's probably not the module you were expecting it to find. This is almost always because of the file name issue I mentioned above, OR because the wrong version of flask has been installed, or something similar. One thing to try would be at the *very* top of counters.py, add the following lines: import flask print(flask) then run your command again, and see what the stdout output is. You should see something like: Does XXXXXX look like the right place for the flask installation? if not, then that's the problem. Steve On Thu, Jul 8, 2021 at 5:08 PM ????? ?????? wrote: > No, the way i have installed flask was under root account with the command > pip3 install flask. > But even if i installed flask under my nikos user account its evene worse > as the file flask is not entered into PATH. > > So i guess as root i have to install flask, but then why cant it import > 'run" ? > > [root at superhost ~]# whereis flask > flask: /usr/local/bin/flask > > ???? ???, 8 ???? 2021 ???? 7:02 ?.?., ?/? Stestagg > ??????: > >> Hi >> >> Do you have a file or folder named 'flask' in the same directory as >> www.py by any chance? >> >> Steve >> >> On Thu, Jul 8, 2021 at 4:50 PM vergos.... at gmail.com < >> vergos.nikolas at gmail.com> wrote: >> >>> i just moved from bottleframework to flask. I changes what needed to be >>> altered to convert the code and when i run it i just get "Internal server >>> error" >>> >>> Running tail -f ../logs/error_log i get no errors. >>> >>> How can i find out what is the culprit here? >>> >>> [nikos at superhost wsgi]$ export FLASK_APP=www.py >>> [nikos at superhost wsgi]$ export FLASK_ENV=development >>> [nikos at superhost wsgi]$ flask run >>> * Serving Flask app 'www.py' (lazy loading) >>> * Environment: development >>> * Debug mode: on >>> Usage: flask run [OPTIONS] >>> Try 'flask run --help' for help. >>> >>> Error: While importing 'www', an ImportError was raised: >>> >>> Traceback (most recent call last): >>> File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line >>> 256, in locate_app >>> __import__(module_name) >>> File "/home/nikos/wsgi/www.py", line 4, in >>> import counters >>> File "/home/nikos/wsgi/counters.py", line 6, in >>> from flask import run, route, request, redirect >>> ImportError: cannot import name 'run' >>> >>> and this is the error_log when tries to be displayed via browser: >>> >>> [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): >>> Failed to exec Python script file '/home/nikos/wsgi/www.py'. >>> >>> [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): >>> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. >>> >>> [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent >>> call last): >>> >>> [Thu Jul 08 15:08:36.436432 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] File >>> "/home/nikos/wsgi/www.py", line 4, in >>> >>> [Thu Jul 08 15:08:36.436436 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] import counters >>> >>> [Thu Jul 08 15:08:36.436441 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] File >>> "/home/nikos/wsgi/counters.py", line 6, in >>> >>> [Thu Jul 08 15:08:36.436444 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] from flask import run, >>> route, request, redirect >>> >>> [Thu Jul 08 15:08:36.436458 2021] [wsgi:error] [pid 575443:tid >>> 139757752112896] [remote 89.210.199.119:6718] ImportError: cannot >>> import name 'run' >>> >>> [Thu Jul 08 15:08:40.075655 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): >>> Failed to exec Python script file '/home/nikos/wsgi/www.py'. >>> >>> [Thu Jul 08 15:08:40.075703 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): >>> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. >>> >>> [Thu Jul 08 15:08:40.075785 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] Traceback (most recent >>> call last): >>> >>> [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] File >>> "/home/nikos/wsgi/www.py", line 4, in >>> >>> [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] import counters >>> >>> [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] File >>> "/home/nikos/wsgi/counters.py", line 6, in >>> >>> [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] from flask import run, >>> route, request, redirect >>> >>> [Thu Jul 08 15:08:40.075825 2021] [wsgi:error] [pid 575443:tid >>> 139757777291008] [remote 89.210.199.119:13389] ImportError: cannot >>> import name 'run' >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >>> >> From vergos.nikolas at gmail.com Thu Jul 8 12:12:59 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Thu, 8 Jul 2021 09:12:59 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: ???? ??????, 8 ??????? 2021 ???? 7:09:49 ?.?. UTC+3, ? ??????? Stestagg ??????: > Hi > > Do you have a file or folder named 'flask' in the same directory as www.py > by any chance? No, the way i have installed flask was under root account with the command pip3 install flask. But even if i installed flask under my nikos user account its evene worse as the file flask is not entered into PATH. So i guess as root i have to install flask, but then why cant it import 'run" ? [root at superhost ~]# whereis flask flask: /usr/local/bin/flask From vergos.nikolas at gmail.com Thu Jul 8 12:29:49 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Thu, 8 Jul 2021 09:29:49 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: <69dd8355-07bc-4648-bc6d-322cc1990d1an@googlegroups.com> ???? ??????, 8 ??????? 2021 ???? 7:16:27 ?.?. UTC+3, ? ??????? Stestagg ??????: > [my reply on the list this time :)] > > That's fine. Sorry, I should have provided more information. > > This type of error that you're gettting /can/ happen if you have the > library correctly installed, but within your project, you have a different > file of the same name as the library. > Then when python tries to import 'flask', it actually imports your local > file, NOT the installed flask. > > You see the error message is *not* saying that python can't find flask, but > that it can't find a name `run` within the flask module: > from flask import run, route, request, redirect > ImportError: cannot import name 'run' > Therefore python has successfully found a module named flask somewhere, > just that it's probably not the module you were expecting it to find. > > This is almost always because of the file name issue I mentioned above, OR > because the wrong version of flask has been installed, or something similar. > > One thing to try would be at the *very* top of counters.py, add the > following lines: > import flask > print(flask) > > then run your command again, and see what the stdout output is. You should > see something like: > > > > Does XXXXXX look like the right place for the flask installation? if not, > then that's the problem. After inserting the lines you told me i get the following when i try to run it via browser [nikos at superhost wsgi]$ tail -f ../logs/error_log [Thu Jul 08 19:22:31.042014 2021] [wsgi:error] [pid 575443:tid 139757777291008] [remote 89.210.199.119:4206] ImportError: cannot import name 'run' [Thu Jul 08 19:22:32.723900 2021] [wsgi:error] [pid 575443:tid 139757752112896] [Thu Jul 08 19:22:32.724068 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:8556] mod_wsgi (pid=575443): Failed to exec Python script file '/home/nikos/wsgi/www.py'. should i try always to run flask via browser or as "flask run" ? os is it the same? From vergos.nikolas at gmail.com Thu Jul 8 13:07:17 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Thu, 8 Jul 2021 10:07:17 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: <6a757bcd-8d10-459c-b4ee-fe5474c8ba6bn@googlegroups.com> ???? ??????, 8 ??????? 2021 ???? 7:16:27 ?.?. UTC+3, ? ??????? Stestagg ??????: > [my reply on the list this time :)] > > That's fine. Sorry, I should have provided more information. > > This type of error that you're gettting /can/ happen if you have the > library correctly installed, but within your project, you have a different > file of the same name as the library. > Then when python tries to import 'flask', it actually imports your local > file, NOT the installed flask. > > You see the error message is *not* saying that python can't find flask, but > that it can't find a name `run` within the flask module: > from flask import run, route, request, redirect > ImportError: cannot import name 'run' > Therefore python has successfully found a module named flask somewhere, > just that it's probably not the module you were expecting it to find. > > This is almost always because of the file name issue I mentioned above, OR > because the wrong version of flask has been installed, or something similar. > > One thing to try would be at the *very* top of counters.py, add the > following lines: > import flask > print(flask) > > then run your command again, and see what the stdout output is. You should > see something like: > > > > Does XXXXXX look like the right place for the flask installation? if not, > then that's the problem. > > Steve > > On Thu, Jul 8, 2021 at 5:08 PM ????? ?????? > wrote: > > No, the way i have installed flask was under root account with the command > > pip3 install flask. > > But even if i installed flask under my nikos user account its evene worse > > as the file flask is not entered into PATH. > > > > So i guess as root i have to install flask, but then why cant it import > > 'run" ? > > > > [root at superhost ~]# whereis flask > > flask: /usr/local/bin/flask > > > > ???? ???, 8 ???? 2021 ???? 7:02 ?.?., ?/? Stestagg > > ??????: > > > >> Hi > >> > >> Do you have a file or folder named 'flask' in the same directory as > >> www.py by any chance? > >> > >> Steve > >> > >> On Thu, Jul 8, 2021 at 4:50 PM vergos.... at gmail.com < > >> vergos.... at gmail.com> wrote: > >> > >>> i just moved from bottleframework to flask. I changes what needed to be > >>> altered to convert the code and when i run it i just get "Internal server > >>> error" > >>> > >>> Running tail -f ../logs/error_log i get no errors. > >>> > >>> How can i find out what is the culprit here? > >>> > >>> [nikos at superhost wsgi]$ export FLASK_APP=www.py > >>> [nikos at superhost wsgi]$ export FLASK_ENV=development > >>> [nikos at superhost wsgi]$ flask run > >>> * Serving Flask app 'www.py' (lazy loading) > >>> * Environment: development > >>> * Debug mode: on > >>> Usage: flask run [OPTIONS] > >>> Try 'flask run --help' for help. > >>> > >>> Error: While importing 'www', an ImportError was raised: > >>> > >>> Traceback (most recent call last): > >>> File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line > >>> 256, in locate_app > >>> __import__(module_name) > >>> File "/home/nikos/wsgi/www.py", line 4, in > >>> import counters > >>> File "/home/nikos/wsgi/counters.py", line 6, in > >>> from flask import run, route, request, redirect > >>> ImportError: cannot import name 'run' > >>> > >>> and this is the error_log when tries to be displayed via browser: > >>> > >>> [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): > >>> Failed to exec Python script file '/home/nikos/wsgi/www.py'. > >>> > >>> [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): > >>> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. > >>> > >>> [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent > >>> call last): > >>> > >>> [Thu Jul 08 15:08:36.436432 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] File > >>> "/home/nikos/wsgi/www.py", line 4, in > >>> > >>> [Thu Jul 08 15:08:36.436436 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] import counters > >>> > >>> [Thu Jul 08 15:08:36.436441 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] File > >>> "/home/nikos/wsgi/counters.py", line 6, in > >>> > >>> [Thu Jul 08 15:08:36.436444 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] from flask import run, > >>> route, request, redirect > >>> > >>> [Thu Jul 08 15:08:36.436458 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] ImportError: cannot > >>> import name 'run' > >>> > >>> [Thu Jul 08 15:08:40.075655 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): > >>> Failed to exec Python script file '/home/nikos/wsgi/www.py'. > >>> > >>> [Thu Jul 08 15:08:40.075703 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): > >>> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. > >>> > >>> [Thu Jul 08 15:08:40.075785 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] Traceback (most recent > >>> call last): > >>> > >>> [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] File > >>> "/home/nikos/wsgi/www.py", line 4, in > >>> > >>> [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] import counters > >>> > >>> [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] File > >>> "/home/nikos/wsgi/counters.py", line 6, in > >>> > >>> [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] from flask import run, > >>> route, request, redirect > >>> > >>> [Thu Jul 08 15:08:40.075825 2021] [wsgi:error] [pid 575443:tid > >>> 139757777291008] [remote 89.210.199.119:13389] ImportError: cannot > >>> import name 'run' > >>> -- > >>> https://mail.python.org/mailman/listinfo/python-list > >>> > >> [nikos at superhost wsgi]$ flask run * Serving Flask app 'www.py' (lazy loading) * Environment: DEVELOPMENT * Debug mode: off Usage: flask run [OPTIONS] Try 'flask run --help' for help. Error: While importing 'www', an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app __import__(module_name) File "/home/nikos/wsgi/www.py", line 4, in import counters File "/home/nikos/wsgi/counters.py", line 9, in from flask import run, route, request, redirect ImportError: cannot import name 'run' What can you undestand out this that? File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app __import__(module_name) From mennoholscher at gmail.com Thu Jul 8 15:50:29 2021 From: mennoholscher at gmail.com (Menno Holscher) Date: Thu, 8 Jul 2021 21:50:29 +0200 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? In-Reply-To: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: Op 08-07-2021 om 15:42 schreef vergos.... at gmail.com: > i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" This error is the error any web site shows when the code of your application has an error. > How can i find out what is the culprit here? > > [nikos at superhost wsgi]$ export FLASK_APP=www.py > [nikos at superhost wsgi]$ export FLASK_ENV=development > [nikos at superhost wsgi]$ flask run > * Serving Flask app 'www.py' (lazy loading) > * Environment: development > * Debug mode: on > Usage: flask run [OPTIONS] > Try 'flask run --help' for help. > > Error: While importing 'www', an ImportError was raised: > > Traceback (most recent call last): > File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app > __import__(module_name) > File "/home/nikos/wsgi/www.py", line 4, in > import counters > File "/home/nikos/wsgi/counters.py", line 6, in > from flask import run, route, request, redirect > ImportError: cannot import name 'run' > When I import flask in the REPL (the Python command processor) and look at what it exports: >>> import flask >>> dir(flask) ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', 'Session', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', 'abort', 'after_this_request', 'app', 'appcontext_popped', 'appcontext_pushed', 'appcontext_tearing_down', 'before_render_template', 'blueprints', 'cli', 'config', 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', 'got_request_exception', 'has_app_context', 'has_request_context', 'helpers', 'json', 'json_available', 'jsonify', 'make_response', 'message_flashed', 'redirect', 'render_template', 'render_template_string', 'request', 'request_finished', 'request_started', 'request_tearing_down', 'safe_join', 'send_file', 'send_from_directory', 'session', 'sessions', 'signals', 'signals_available', 'stream_with_context', 'template_rendered', 'templating', 'url_for', 'wrappers'] ... there is no "run" there. What were you trying to achieve? If you are thinking about the "flask run" mentioned in startup, that is a bash/cmd command, an easy way to start the server from the command line: (venv):~/python/debtors> export FLASK_APP=debtors ; flask run * Serving Flask app "debtors" * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) -- Met vriendelijke groet / Kind regards Menno H?lscher From vergos.nikolas at gmail.com Fri Jul 9 02:14:20 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Thu, 8 Jul 2021 23:14:20 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> Message-ID: <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> ???? ?????????, 9 ??????? 2021 ???? 12:03:00 ?.?. UTC+3, ? ??????? Menno Holscher ??????: > Op 08-07-2021 om 15:42 schreef vergos.... at gmail.com: > > i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" > This error is the error any web site shows when the code of your > application has an error. > > How can i find out what is the culprit here? > > > > [nikos at superhost wsgi]$ export FLASK_APP=www.py > > [nikos at superhost wsgi]$ export FLASK_ENV=development > > [nikos at superhost wsgi]$ flask run > > * Serving Flask app 'www.py' (lazy loading) > > * Environment: development > > * Debug mode: on > > Usage: flask run [OPTIONS] > > Try 'flask run --help' for help. > > > > Error: While importing 'www', an ImportError was raised: > > > > Traceback (most recent call last): > > File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app > > __import__(module_name) > > File "/home/nikos/wsgi/www.py", line 4, in > > import counters > > File "/home/nikos/wsgi/counters.py", line 6, in > > from flask import run, route, request, redirect > > ImportError: cannot import name 'run' > > > When I import flask in the REPL (the Python command processor) and look > at what it exports: > > >>> import flask > >>> dir(flask) > ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', > 'Session', '__builtins__', '__cached__', '__doc__', '__file__', > '__loader__', '__name__', '__package__', '__path__', '__spec__', > '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', > 'abort', 'after_this_request', 'app', 'appcontext_popped', > 'appcontext_pushed', 'appcontext_tearing_down', > 'before_render_template', 'blueprints', 'cli', 'config', > 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', > 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', > 'got_request_exception', 'has_app_context', 'has_request_context', > 'helpers', 'json', 'json_available', 'jsonify', 'make_response', > 'message_flashed', 'redirect', 'render_template', > 'render_template_string', 'request', 'request_finished', > 'request_started', 'request_tearing_down', 'safe_join', 'send_file', > 'send_from_directory', 'session', 'sessions', 'signals', > 'signals_available', 'stream_with_context', 'template_rendered', > 'templating', 'url_for', 'wrappers'] > ... there is no "run" there. What were you trying to achieve? > > If you are thinking about the "flask run" mentioned in startup, that is > a bash/cmd command, an easy way to start the server from the command line: > > (venv):~/python/debtors> export FLASK_APP=debtors ; flask run > * Serving Flask app "debtors" > * Environment: production > WARNING: This is a development server. Do not use it in a production > deployment. > Use a production WSGI server instead. > * Debug mode: off > * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) > > > -- > Met vriendelijke groet / Kind regards > > Menno H?lscher Now it complains it cannot find the module route. How is that even possible? Do i have something wrong in the www.py? from flask import Flask, route, request, redirect, render_template, url_for, send_from_directory, debug app = Flask(__name__) app.run(debug=True) [nikos at superhost wsgi]$ flask run * Serving Flask app 'www.py' (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off Usage: flask run [OPTIONS] Try 'flask run --help' for help. Error: While importing 'www', an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app __import__(module_name) File "/home/nikos/wsgi/www.py", line 4, in import counters File "/home/nikos/wsgi/counters.py", line 9, in from flask import route, request, redirect ImportError: cannot import name 'route' Also i use run for this app.run( host='superhost.gr', port=5000, debug=True ) From mennoholscher at gmail.com Fri Jul 9 07:33:47 2021 From: mennoholscher at gmail.com (Menno Holscher) Date: Fri, 9 Jul 2021 13:33:47 +0200 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: Op 09-07-2021 om 08:14 schreef vergos.... at gmail.com: > ???? ?????????, 9 ??????? 2021 ???? 12:03:00 ?.?. UTC+3, ? ??????? Menno Holscher ??????: >> Op 08-07-2021 om 15:42 schreef vergos.... at gmail.com: >>>>> import flask >>>>> dir(flask) >> ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', >> 'Session', '__builtins__', '__cached__', '__doc__', '__file__', >> '__loader__', '__name__', '__package__', '__path__', '__spec__', >> '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', >> 'abort', 'after_this_request', 'app', 'appcontext_popped', >> 'appcontext_pushed', 'appcontext_tearing_down', >> 'before_render_template', 'blueprints', 'cli', 'config', >> 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', >> 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', >> 'got_request_exception', 'has_app_context', 'has_request_context', >> 'helpers', 'json', 'json_available', 'jsonify', 'make_response', >> 'message_flashed', 'redirect', 'render_template', >> 'render_template_string', 'request', 'request_finished', >> 'request_started', 'request_tearing_down', 'safe_join', 'send_file', >> 'send_from_directory', 'session', 'sessions', 'signals', >> 'signals_available', 'stream_with_context', 'template_rendered', >> 'templating', 'url_for', 'wrappers'] >> ... there is no "run" there. What were you trying to achieve? >> When you look at the exported symbols, there is no route, so if you expected flask to export route it is not there either. > How is that even possible? > > Do i have something wrong in the www.py? > > from flask import Flask, route, request, redirect, render_template, url_for, send_from_directory, debug > > app = Flask(__name__) > app.run(debug=True) There is 2 possibilities here. One is you have a module named route. Than you do not import it as a name from flask, but as a module. The other is you are looking for the attribute route from the Flask class. @app.route("/item/", methods=["GET", "POST"]) This creates a route. The route method is a method of an instance of Flask (i.e. app), so importing Flask is enough. > > Also i use run for this > > app.run( host='superhost.gr', port=5000, debug=True ) > Yes, that is OK, if DNS contains a host superhost.gr. -- Met vriendelijke groet / Kind regards Menno H?lscher From vergos.nikolas at gmail.com Fri Jul 9 09:01:51 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Fri, 9 Jul 2021 06:01:51 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: ???? ?????????, 9 ??????? 2021 ???? 3:57:11 ?.?. UTC+3, ? ??????? Menno Holscher ??????: > Op 09-07-2021 om 08:14 schreef vergos.... at gmail.com: > > ???? ?????????, 9 ??????? 2021 ???? 12:03:00 ?.?. UTC+3, ? ??????? Menno Holscher ??????: > >> Op 08-07-2021 om 15:42 schreef vergos.... at gmail.com: > >>>>> import flask > >>>>> dir(flask) > >> ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', > >> 'Session', '__builtins__', '__cached__', '__doc__', '__file__', > >> '__loader__', '__name__', '__package__', '__path__', '__spec__', > >> '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', > >> 'abort', 'after_this_request', 'app', 'appcontext_popped', > >> 'appcontext_pushed', 'appcontext_tearing_down', > >> 'before_render_template', 'blueprints', 'cli', 'config', > >> 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', > >> 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', > >> 'got_request_exception', 'has_app_context', 'has_request_context', > >> 'helpers', 'json', 'json_available', 'jsonify', 'make_response', > >> 'message_flashed', 'redirect', 'render_template', > >> 'render_template_string', 'request', 'request_finished', > >> 'request_started', 'request_tearing_down', 'safe_join', 'send_file', > >> 'send_from_directory', 'session', 'sessions', 'signals', > >> 'signals_available', 'stream_with_context', 'template_rendered', > >> 'templating', 'url_for', 'wrappers'] > >> ... there is no "run" there. What were you trying to achieve? > >> > When you look at the exported symbols, there is no route, so if you > expected flask to export route it is not there either. > > How is that even possible? > > > > Do i have something wrong in the www.py? > > > > from flask import Flask, route, request, redirect, render_template, url_for, send_from_directory, debug > > > > app = Flask(__name__) > > app.run(debug=True) > There is 2 possibilities here. One is you have a module named route. > Than you do not import it as a name from flask, but as a module. > > The other is you are looking for the attribute route from the Flask class. > > @app.route("/item/", methods=["GET", "POST"]) > > This creates a route. The route method is a method of an instance of > Flask (i.e. app), so importing Flask is enough. > > > > Also i use run for this > > > > app.run( host='superhost.gr', port=5000, debug=True ) > > > Yes, that is OK, if DNS contains a host superhost.gr. > -- > Met vriendelijke groet / Kind regards > > Menno H?lscher please tell me what i need to do to be able to see error messages in browser and not only via console: app = Flask(__name__) app.debug = True application = app The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? From rosuav at gmail.com Fri Jul 9 09:09:57 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 9 Jul 2021 23:09:57 +1000 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: On Fri, Jul 9, 2021 at 11:07 PM vergos.... at gmail.com wrote: > please tell me what i need to do to be able to see error messages in browser and not only via console: > > app = Flask(__name__) > app.debug = True > application = app > > The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? Until you're able to serve pages, you won't get anything in the browser. Nikos, you've come back to this list a few times over the years, and each time, you're trying to host web sites with a very shaky understanding of what's actually going on. Are you still trying to provide hosting services to other people, and if so, have you - as was advised multiple times in the past - dedicated a week to actually learning how HTTP works and how web browsers and back end apps communicate? ChrisA From vergos.nikolas at gmail.com Fri Jul 9 09:16:59 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Fri, 9 Jul 2021 06:16:59 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: <3cd4238b-81db-439b-97b6-69f41e8facedn@googlegroups.com> ???? ?????????, 9 ??????? 2021 ???? 4:10:29 ?.?. UTC+3, ? ??????? Chris Angelico ??????: > On Fri, Jul 9, 2021 at 11:07 PM vergos.... at gmail.com > wrote: > > please tell me what i need to do to be able to see error messages in browser and not only via console: > > > > app = Flask(__name__) > > app.debug = True > > application = app > > > > The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? > Until you're able to serve pages, you won't get anything in the browser. > > Nikos, you've come back to this list a few times over the years, and > each time, you're trying to host web sites with a very shaky > understanding of what's actually going on. Are you still trying to > provide hosting services to other people, and if so, have you - as was > advised multiple times in the past - dedicated a week to actually > learning how HTTP works and how web browsers and back end apps > communicate? > > ChrisA This is a perosnal project of mine. Iam abl to server the page i want, its just in a specific function i get an error and that error is being displayed on console, and i'am trying to make it seen via browser instead. Isn't app.debug = True enough to do that? eveb if i add app.testing=True i still cant see the errors in the browser. From vergos.nikolas at gmail.com Fri Jul 9 09:33:47 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Fri, 9 Jul 2021 06:33:47 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: <3658d083-9611-44d5-b2d7-3eb24ee48ec6n@googlegroups.com> ???? ?????????, 9 ??????? 2021 ???? 4:10:29 ?.?. UTC+3, ? ??????? Chris Angelico ??????: > On Fri, Jul 9, 2021 at 11:07 PM vergos.... at gmail.com > wrote: > > please tell me what i need to do to be able to see error messages in browser and not only via console: > > > > app = Flask(__name__) > > app.debug = True > > application = app > > > > The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? > Until you're able to serve pages, you won't get anything in the browser. > > Nikos, you've come back to this list a few times over the years, and > each time, you're trying to host web sites with a very shaky > understanding of what's actually going on. Are you still trying to > provide hosting services to other people, and if so, have you - as was > advised multiple times in the past - dedicated a week to actually > learning how HTTP works and how web browsers and back end apps > communicate? > > ChrisA from werkzeug.debug import DebuggedApplication app = Flask(__name__) application = app application = DebuggedApplication(app, True) I even tries this solution and i still see errors appear *only* in the error_log. WHY?! From komendantyan.artem at gmail.com Fri Jul 9 11:29:12 2021 From: komendantyan.artem at gmail.com (=?UTF-8?B?0JDRgNGC0LXQvCDQmtC+0LzQtdC90LTQsNC90YLRj9C9?=) Date: Fri, 9 Jul 2021 18:29:12 +0300 Subject: Correct traceback for multiline chain of method calling Message-ID: Hello! There is a code https://pastebin.com/0NLsHuLa. It has a multiline chain of method calling, when some method fails. In python3.7 it fails in a row which corresponds to the failing method, in python3.9 it corresponds to the very first line. Another similar example is https://pastebin.com/2P9snnMn The error is on the first line for older pythons too. I propose to have a line with the method name in traceback if this method fails. I develop some library when it is very popular among users to declare some operations with such multiline chains. Also I want to keep correct traceback for each operation because the first line is not very informative when some method occurred more than once in this chain. Can this improvement be done? Maybe anybody has any other suggestions on how to get the correct line in traceback right now? -- Best wishes, Artem Komendantian komendantyan.artem at gmail.com From drsalists at gmail.com Fri Jul 9 12:39:33 2021 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 9 Jul 2021 09:39:33 -0700 Subject: Verify independence and uniform distribution of discrete values in Python? Message-ID: I've posted a question about CPython 3.[0-9]'s random.SystemRandom().choice(list_) at https://stackoverflow.com/questions/68319071/verify-independence-and-uniform-distribution-of-discrete-values-in-python In short, we need to be able to support CPython's a little older than the secrets module goes back, but we still need independence and uniform distribution - in fact, we need cryptographic strength randomness. Does anyone know if SystemRandom() is cryptographically strong in CPython >= 3.0? It appears that the good module secrets is cryptographically strong, but doesn't go back in CPython 3.x's history far enough, and it appears to build on random.SystemRandom(). Thanks! From mennoholscher at gmail.com Fri Jul 9 15:41:34 2021 From: mennoholscher at gmail.com (Menno Holscher) Date: Fri, 9 Jul 2021 21:41:34 +0200 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: Op 09-07-2021 om 15:01 schreef vergos.... at gmail.com: > please tell me what i need to do to be able to see error messages in browser and not only via console: > > app = Flask(__name__) > app.debug = True > application = app > > The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? > This is totally unrelated to your earlier question, and (as many things Flask) well documented. Look at https://flask.palletsprojects.com/en/2.0.x/debugging/#the-built-in-debugger -- Met vriendelijke groet / Kind regards Menno H?lscher From vergos.nikolas at gmail.com Fri Jul 9 17:09:55 2021 From: vergos.nikolas at gmail.com (vergos....@gmail.com) Date: Fri, 9 Jul 2021 14:09:55 -0700 (PDT) Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: ???? ?????????, 9 ??????? 2021 ???? 11:48:43 ?.?. UTC+3, ? ??????? Menno Holscher ??????: > Op 09-07-2021 om 15:01 schreef vergos.... at gmail.com: > > please tell me what i need to do to be able to see error messages in browser and not only via console: > > > > app = Flask(__name__) > > app.debug = True > > application = app > > > > The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? > > > This is totally unrelated to your earlier question, and (as many things > Flask) well documented. > > Look at > https://flask.palletsprojects.com/en/2.0.x/debugging/#the-built-in-debugger > -- > Met vriendelijke groet / Kind regards > > Menno H?lscher i managed to run i with built in debugger by setting export FLASK_ENV=development Every time I start up my flask app the environment variable is set to production. I want to have it set to development mode by default. Otherwise every time I start my app i have to run .. export FLASK_ENV=development How can I set environment's default value as development in every startup? From ethan at stoneleaf.us Fri Jul 9 18:03:31 2021 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 9 Jul 2021 15:03:31 -0700 Subject: Verify independence and uniform distribution of discrete values in Python? In-Reply-To: References: Message-ID: From Tim Peters: > `secrets` is just a wrapper around `random.SystemRandom`, so the > presence or absence of `secrets` doesn't matter. > > As to SystemRandom, all answers depend on the quality of the platform > os.urandom(), which Python has no control over. See my answer here, > and the comments on it: > > https://stackoverflow.com/questions/20936993/ From cs at cskk.id.au Fri Jul 9 19:03:01 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 10 Jul 2021 09:03:01 +1000 Subject: Correct traceback for multiline chain of method calling In-Reply-To: References: Message-ID: On 09Jul2021 18:29, ????? ??????????? wrote: >There is a code https://pastebin.com/0NLsHuLa. >It has a multiline chain of method calling, when some method fails. In >python3.7 it fails in a row which corresponds to the failing method, in >python3.9 it corresponds to the very first line. > >Another similar example is https://pastebin.com/2P9snnMn >The error is on the first line for older pythons too. Interesting. There was some work done in recent Pythons to improve syntax error reporting. I wonder if it has had side effects on the reporting. >I propose to have a line with the method name in traceback if this >method >fails. That line is already there: # File "/home/komendart/temp/script.py", line 6, in fail # raise RuntimeError('fail') See that it points at the fail() method from line 6 of the script? >I develop some library when it is very popular among users to declare some >operations with such multiline chains. Also I want to keep correct >traceback for each operation because the first line is not very informative >when some method occurred more than once in this chain. > >Can this improvement be done? Maybe anybody has any other suggestions on >how to get the correct line in traceback right now? Aside from putting the whole thing on 1 line? Joking. Possibly only by breaking it up purely while debugging: x = a.do_nothing() x = x.do_nothing() x = x.fail(True) and so forth. Annoying, but it would providethe desired precision. Cheers, Cameron Simpson From komendantyan.artem at gmail.com Fri Jul 9 21:28:25 2021 From: komendantyan.artem at gmail.com (Artem Komendantian) Date: Sat, 10 Jul 2021 04:28:25 +0300 Subject: Correct traceback for multiline chain of method calling In-Reply-To: References: Message-ID: > That line is already there: > # File "/home/komendart/temp/script.py", line 6, in fail > # raise RuntimeError('fail') Probably I should rewrite more concretely. I have such traceback ending for python3.7 # File "script.py", line 15, in main # .fail(True) # File "script.py", line 6, in fail # raise RuntimeError('fail') It has the exact line of the failing method's call (line 15) and that is what I want for fresh python in general. Just the name of the method and place inside of it with error in the last part of traceback is not enough because this method can occur in the chain several times (like .fail in my simple example) and I want to get a line of the exact call. > Annoying, but it would provide the desired precision. I agree with all parts of this sentence :) Well, I can live with such a solution but it is really uncomfortable. In python3.7 and lower (even in python2, lol) if a method was called with some arguments traceback had a line corresponding to some argument of needed call. This behaviour was suitable for me. I can a bit formalize my suggestion to improve python tracebacks. If we have code in one line like ( (some complex construction of object with __call__) ( some arguments ) ) traceback should contain a line with opening brace before arguments (Now in the last python traceback seems to contain the start of the called object's construction) The last line of called object's construction or first of arguments enumerating is ok too, it doesn't really matter for me. BTW it is not important for me but I can dream how this proposal can be generalized. For example for failing index operations a[b] (error line must be close to [ here) or for all binary operations (a + b fails => the error line must be close to the line with plus operator). Does it sound reasonable? Am I on the right mailing list for python improvement suggestions? :) -- Best wishes, Artem Komendantian komendantyan.artem at gmail.com ??, 10 ???. 2021 ?. ? 02:53, Cameron Simpson : > On 09Jul2021 18:29, ????? ??????????? > wrote: > >There is a code https://pastebin.com/0NLsHuLa. > >It has a multiline chain of method calling, when some method fails. In > >python3.7 it fails in a row which corresponds to the failing method, in > >python3.9 it corresponds to the very first line. > > > >Another similar example is https://pastebin.com/2P9snnMn > >The error is on the first line for older pythons too. > > Interesting. > > There was some work done in recent Pythons to improve syntax error > reporting. I wonder if it has had side effects on the reporting. > > >I propose to have a line with the method name in traceback if this > >method > >fails. > > That line is already there: > > # File "/home/komendart/temp/script.py", line 6, in fail > # raise RuntimeError('fail') > > See that it points at the fail() method from line 6 of the script? > > >I develop some library when it is very popular among users to declare some > >operations with such multiline chains. Also I want to keep correct > >traceback for each operation because the first line is not very > informative > >when some method occurred more than once in this chain. > > > >Can this improvement be done? Maybe anybody has any other suggestions on > >how to get the correct line in traceback right now? > > Aside from putting the whole thing on 1 line? Joking. > > Possibly only by breaking it up purely while debugging: > > x = a.do_nothing() > x = x.do_nothing() > x = x.fail(True) > > and so forth. Annoying, but it would providethe desired precision. > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > From __peter__ at web.de Sat Jul 10 03:20:08 2021 From: __peter__ at web.de (Peter Otten) Date: Sat, 10 Jul 2021 09:20:08 +0200 Subject: Correct traceback for multiline chain of method calling In-Reply-To: References: Message-ID: On 09/07/2021 17:29, ????? ??????????? wrote: > Hello! > > There is a code https://pastebin.com/0NLsHuLa. > It has a multiline chain of method calling, when some method fails. In > python3.7 it fails in a row which corresponds to the failing method, in > python3.9 it corresponds to the very first line. > > Another similar example is https://pastebin.com/2P9snnMn > The error is on the first line for older pythons too. > > I propose to have a line with the method name in traceback if this method > fails. > > I develop some library when it is very popular among users to declare some > operations with such multiline chains. Also I want to keep correct > traceback for each operation because the first line is not very informative > when some method occurred more than once in this chain. > > Can this improvement be done? Maybe anybody has any other suggestions on > how to get the correct line in traceback right now? If I understand you correctly there's hope; the upcoming Python 3.10 will show the failing method call: Python 3.10.0b3 (tags/v3.10.0b3:865714a, Jun 17 2021, 20:19:11) [MSC v.1929 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. class A: def chain(self): return self def fail(self): 1/0 (A() .chain() .chain() .fail() .chain() ) Traceback (most recent call last): File "", line 4, in .fail() File "", line 3, in fail def fail(self): 1/0 ZeroDivisionError: division by zero From greg.ewing at canterbury.ac.nz Sat Jul 10 20:06:11 2021 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 11 Jul 2021 12:06:11 +1200 Subject: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit her In-Reply-To: References: <0c2bd594-bada-47bd-a20a-9bffe8c106e2n@googlegroups.com> <735217a3-c15e-4b8f-b695-27534cabb7e6n@googlegroups.com> Message-ID: On 11/07/21 2:24 am, Dennis Lee Bieber wrote: > Off-hand, that looks like a BASH command, so stuff it in your .bashrc > or .profile and see what happens. Or make yourself a little shell script that starts flask with the appopriate settings. -- Greg From pablogsal at gmail.com Sat Jul 10 21:46:46 2021 From: pablogsal at gmail.com (Pablo Galindo Salgado) Date: Sun, 11 Jul 2021 02:46:46 +0100 Subject: [RELEASE] Python 3.10.0b4 is available Message-ID: Wow! A release on a Saturday? Do the release management team even rest? You better believe it, because this is the last of the planned beta releases. This means that the next pre-release will be the first release candidate of Python 3.10.0. Remember that our goal is to have no ABI changes after this beta and a few code changes as possible after 3.10.0rc1. https://www.python.org/downloads/release/python-3100b4/ #This is a beta preview of Python 3.10 Python 3.10 is still in development. 3.10.0b4 is the fourth and last of the beta release previews. Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their projects to support the new feature release. We strongly encourage maintainers of third-party Python projects to test with 3.10 during the beta phase and report issues found to the Python bug tracker as soon as possible. While the release is planned to be feature complete entering the beta phase, it is possible that features may be modified or, in rare cases, deleted up until the start of the release candidate phase (Monday, 2021-08-02). Our goal is to have no ABI changes after beta 4 and as few code changes as possible after 3.10.0rc1, the first release candidate. To achieve that, it will be extremely important to get as much exposure for 3.10 as possible during the beta phase. Please keep in mind that this is a preview release and its use is not recommended for production environments. The next pre-release, the first release candidate of Python 3.10.0, will be 3.10.0rc1. It is currently scheduled for Monday, 2021-08-02. #And now for something completely different In quantum physics, the spin is an intrinsic form of angular momentum carried by elementary particles, composite particles, and atomic nuclei. The spin is one of two types of angular momentum in quantum mechanics, the other being orbital angular momentum. The orbital angular momentum operator is the quantum-mechanical counterpart to the classical angular momentum of orbital revolution and appears when there is periodic structure to its wavefunction as the angle varies. For photons, spin is the quantum-mechanical counterpart of the polarization of light; for electrons, the spin has no classical counterpart. # We hope you enjoy those new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. Regards from very cloudy London, Your friendly release team, Pablo Galindo @pablogsal Ned Deily @nad Steve Dower @steve.dower From mail.python.org at marchello.tk Mon Jul 12 05:07:59 2021 From: mail.python.org at marchello.tk (Marchello) Date: Mon, 12 Jul 2021 12:07:59 +0300 Subject: pandas - get subelements Message-ID: Hi team, My need is to extract particular sub-elements (ContactId and AssociatedEntity) from below json using pandas. Json: { "odata.metadata": "https://example1.com/odata/$metadata#Contacts", "value": [ { "Addresses": [ { "ContactId": "35aa05d1-21c7-493d-96e3-00003c966732", "AssociatedEntity": "ac7a9ec8-b71b-486b-8b3b-41b6bc11f936" } ], "ContactId2": "35aa05d1-21c7-493d-96e3-00003c966732" }, { "Addresses": [ { "ContactId": "ca717463-734d-4f2f-a01e-00006ff0c806", "AssociatedEntity": "bda08493-7ae0-47cf-8d3a-f1a486498836" } ], "ContactId2": "ca717463-734d-4f2f-a01e-00006ff0c806" } ] } My code so far: import json import pandas as pd txt1 = '{"odata.metadata":"https://example1.com/odata/$metadata#Contacts","value":[ { "Addresses":[ { "ContactId":"35aa05d1-21c7-493d-96e3-00003c966732","AssociatedEntity":"ac7a9ec8-b71b-486b-8b3b-41b6bc11f936" } ],"ContactId2":"35aa05d1-21c7-493d-96e3-00003c966732" },{ "Addresses":[ { "ContactId":"ca717463-734d-4f2f-a01e-00006ff0c806","AssociatedEntity":"bda08493-7ae0-47cf-8d3a-f1a486498836" } ],"ContactId2":"ca717463-734d-4f2f-a01e-00006ff0c806" }]}' json2 = json.loads(txt1) print("json:\n") print(json2) df = pd.json_normalize(json2['value']) print("\npandas df (1):\n") df1a = df['Addresses'].copy() print(df1a) > pandas df (1): > 0 [{'ContactId': '35aa05d1-21c7-493d-96e3-00003c... > 1 [{'ContactId': 'ca717463-734d-4f2f-a01e-00006f... > Name: Addresses, dtype: object Now how do I get ContactId and AssociatedEntity? Please advise. Best, Marchello From mail.python.org at marchello.tk Mon Jul 12 14:54:15 2021 From: mail.python.org at marchello.tk (Marchello) Date: Mon, 12 Jul 2021 21:54:15 +0300 Subject: pandas - get subelements In-Reply-To: References: Message-ID: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> Hi team, It worked for me this way: > df3 = pd.json_normalize(json2["value"], "Addresses") > print(df3) > ContactId AssociatedEntity > 0 35aa05d1-21c7-493d-96e3-00003c966732 > ac7a9ec8-b71b-486b-8b3b-41b6bc11f936 > 1 ca717463-734d-4f2f-a01e-00006ff0c806 > bda08493-7ae0-47cf-8d3a-f1a486498836 Solved. On 2021-07-12 12:07, Marchello wrote: > Hi team, > > My need is to extract particular sub-elements (ContactId and > AssociatedEntity) from below json using pandas. > > > Json: > > { > "odata.metadata": "https://example1.com/odata/$metadata#Contacts", > "value": [ > { > "Addresses": [ > { > "ContactId": "35aa05d1-21c7-493d-96e3-00003c966732", > "AssociatedEntity": "ac7a9ec8-b71b-486b-8b3b-41b6bc11f936" > } > ], > "ContactId2": "35aa05d1-21c7-493d-96e3-00003c966732" > }, > { > "Addresses": [ > { > "ContactId": "ca717463-734d-4f2f-a01e-00006ff0c806", > "AssociatedEntity": "bda08493-7ae0-47cf-8d3a-f1a486498836" > } > ], > "ContactId2": "ca717463-734d-4f2f-a01e-00006ff0c806" > } > ] > } > > > My code so far: > > import json > import pandas as pd > txt1 = > '{"odata.metadata":"https://example1.com/odata/$metadata#Contacts","value":[ > { "Addresses":[ { > "ContactId":"35aa05d1-21c7-493d-96e3-00003c966732","AssociatedEntity":"ac7a9ec8-b71b-486b-8b3b-41b6bc11f936" > } ],"ContactId2":"35aa05d1-21c7-493d-96e3-00003c966732" > },{ "Addresses":[ { > "ContactId":"ca717463-734d-4f2f-a01e-00006ff0c806","AssociatedEntity":"bda08493-7ae0-47cf-8d3a-f1a486498836" > } ],"ContactId2":"ca717463-734d-4f2f-a01e-00006ff0c806" > }]}' > json2 = json.loads(txt1) > print("json:\n") > print(json2) > df = pd.json_normalize(json2['value']) > print("\npandas df (1):\n") > df1a = df['Addresses'].copy() > print(df1a) > >> pandas df (1): >> 0 [{'ContactId': '35aa05d1-21c7-493d-96e3-00003c... >> 1 [{'ContactId': 'ca717463-734d-4f2f-a01e-00006f... >> Name: Addresses, dtype: object > > Now how do I get ContactId and AssociatedEntity? > Please advise. Best, Marchello From lucas at bourneuf.net Mon Jul 12 15:12:26 2021 From: lucas at bourneuf.net (lucas) Date: Mon, 12 Jul 2021 21:12:26 +0200 Subject: argparse support of/by argparse In-Reply-To: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> References: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> Message-ID: <8f7a5f6d-6b64-24ab-4140-1c83bd6a533b@bourneuf.net> Hello everyone, Let us consider this patch of code: import argparse def parse_cli() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument('n', type=int) return parser.parse_args() args = parse_cli() print(args.n + ' ') # type error Running CPython on it will raise a TypeError, and running Mypy on it will indicate that no issues were found. I was wondering if there is any way for me to have mypy detecting the args.n type, based on the type keyword of the parser.add_argument function ? It appears that some type annotations were added to tierce party modules, provided by mypy itself. Is there a technical issue preventing such work to be made for argparse (or other CLI ; i didn't find anything for others either) Thank you for reading, --lucas From rosuav at gmail.com Mon Jul 12 15:33:45 2021 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 13 Jul 2021 05:33:45 +1000 Subject: argparse support of/by argparse In-Reply-To: <8f7a5f6d-6b64-24ab-4140-1c83bd6a533b@bourneuf.net> References: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> <8f7a5f6d-6b64-24ab-4140-1c83bd6a533b@bourneuf.net> Message-ID: On Tue, Jul 13, 2021 at 5:22 AM lucas wrote: > > Hello everyone, > > Let us consider this patch of code: > > import argparse > > def parse_cli() -> argparse.Namespace: > parser = argparse.ArgumentParser() > parser.add_argument('n', type=int) > return parser.parse_args() > > args = parse_cli() > print(args.n + ' ') # type error > > Running CPython on it will raise a TypeError, and running Mypy on it > will indicate that no issues were found. > > I was wondering if there is any way for me to have mypy detecting the > args.n type, based on the type keyword of the parser.add_argument function ? > > It appears that some type annotations were added to tierce party > modules, provided by mypy itself. Is there a technical issue preventing > such work to be made for argparse (or other CLI ; i didn't find anything > for others either) > Seems complicated, since it depends on a lot of run-time information. What if you flip the problem on its head? Instead of creating the argparser and letting that govern the types, maybe create a dataclass, and then programmatically build the parser. from dataclasses import dataclass import argparse @dataclass class Args: n: int def parse_cli() -> Args: parser = argparse.ArgumentParser() for field, typ in Args.__dataclass_fields__.items(): if hasattr(typ, "type"): typ = typ.type # Python 3.10 changed things a bit parser.add_argument(field, type=typ) return Args(**vars(parser.parse_args())) args = parse_cli() print(args.n + ' ') Only barely tested it and didn't try MyPy, but that's the basic idea. You'd have to figure out the tidiest way to define all the other attributes of your arguments (help text, etc), but ideally, all the info should be able to be coded in the dataclass. Incidentally, you could choose to make parse_cli into a classmethod of Args. Might be cleaner. ChrisA From gurvaah at gmail.com Tue Jul 13 05:05:24 2021 From: gurvaah at gmail.com (rubiks solver) Date: Tue, 13 Jul 2021 10:05:24 +0100 Subject: Python does not work Message-ID: <255E7072-6B25-4AEC-BA89-054BD58A9C40@hxcore.ol> When I run python 3.9.6 on visual studio code it opens multiple python setup windows. I rebooted my computer. Same result. Is this a bug? From loris.bennett at fu-berlin.de Tue Jul 13 03:50:19 2021 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Tue, 13 Jul 2021 09:50:19 +0200 Subject: Simple SSL client hangs Message-ID: <871r821wlg.fsf@hornfels.zedat.fu-berlin.de> Hi, In Perl I have the following use IO::Socket::SSL; my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere, PeerPort => 12345, ); my $line = <$my_socket>; print("$line\n"); say $my_socket 'ECHO 1'; $line = <$my_socket>; print("$line\n"); This runs as expected and I get 200 Some Server Somewhere - Hello [123.456.789.123] 310 Hello Echo If I try the same with the following Python code: import socket import ssl HOST = "some.server.somewhere" PORT = 12345 context = ssl.create_default_context() with socket.create_connection((HOST, PORT)) as sock: with context.wrap_socket(sock, server_hostname=HOST) as ssock: data = ssock.recv(1024) print(data.decode()) ssock.write(b'ECHO 1') data = ssock.read(1024) print(data.decode()) I get a timeout for the 'ECHO' command: 200 Some Server Somewhere - Hello [123.456.789.123] 501 Timeout Does anyone have an idea what I might be doing wrong? Cheers, Loris -- This signature is currently under construction. From nr201504 at gmail.com Tue Jul 13 10:54:32 2021 From: nr201504 at gmail.com (Douglas Wells) Date: Tue, 13 Jul 2021 10:54:32 -0400 (EDT) Subject: Simple SSL client hangs References: <871r821wlg.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <1626188072.34643@nowhere.invalid> In article <871r821wlg.fsf at hornfels.zedat.fu-berlin.de>, Loris Bennett wrote: >In Perl I have the following > > use IO::Socket::SSL; > my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere, > PeerPort => 12345, > ); > my $line = <$my_socket>; > print("$line\n"); > say $my_socket 'ECHO 1'; > $line = <$my_socket>; > print("$line\n"); > >This runs as expected and I get > > 200 Some Server Somewhere - Hello [123.456.789.123] > 310 Hello Echo > >If I try the same with the following Python code: > > import socket > import ssl > HOST = "some.server.somewhere" > PORT = 12345 > context = ssl.create_default_context() > with socket.create_connection((HOST, PORT)) as sock: > with context.wrap_socket(sock, server_hostname=HOST) as ssock: > data = ssock.recv(1024) > print(data.decode()) > ssock.write(b'ECHO 1') > data = ssock.read(1024) > print(data.decode()) > >I get a timeout for the 'ECHO' command: > > 200 Some Server Somewhere - Hello [123.456.789.123] > 501 Timeout > >Does anyone have an idea what I might be doing wrong? Loris, You don't specify the type of your server, but it looks like a "normal" SMTP or NNTP or whatever server. This type of server is line oriented. The Perl "say" operation adds a trailing line terminator. The Python "ssl:write" does not. Try adding an appropriate line terminator to your Python code. Most likely it needs to be CR-LF. Perhaps use "ssock.write(b'ECHO 1\r\n') - dmw From python at mrabarnett.plus.com Tue Jul 13 12:51:03 2021 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 13 Jul 2021 17:51:03 +0100 Subject: Simple SSL client hangs In-Reply-To: <871r821wlg.fsf@hornfels.zedat.fu-berlin.de> References: <871r821wlg.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <90db8099-786a-db88-9cff-6c15bd43d958@mrabarnett.plus.com> On 2021-07-13 08:50, Loris Bennett wrote: > Hi, > > In Perl I have the following > > use IO::Socket::SSL; > > my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere, > PeerPort => 12345, > ); > > my $line = <$my_socket>; > print("$line\n"); > say $my_socket 'ECHO 1'; > $line = <$my_socket>; > print("$line\n"); > > This runs as expected and I get > > 200 Some Server Somewhere - Hello [123.456.789.123] > > 310 Hello Echo > > If I try the same with the following Python code: > > import socket > import ssl > > HOST = "some.server.somewhere" > PORT = 12345 > > context = ssl.create_default_context() > > with socket.create_connection((HOST, PORT)) as sock: > with context.wrap_socket(sock, server_hostname=HOST) as ssock: > data = ssock.recv(1024) > print(data.decode()) > ssock.write(b'ECHO 1') > data = ssock.read(1024) > print(data.decode()) > > I get a timeout for the 'ECHO' command: > > 200 Some Server Somewhere - Hello [123.456.789.123] > > 501 Timeout > > Does anyone have an idea what I might be doing wrong? > The docs for Perl says that 'say' appends a newline. On the other hand, 'ssock.write' doesn't append a newline. Could that be the problem? From mats at wichmann.us Tue Jul 13 12:51:33 2021 From: mats at wichmann.us (Mats Wichmann) Date: Tue, 13 Jul 2021 10:51:33 -0600 Subject: Python does not work In-Reply-To: <255E7072-6B25-4AEC-BA89-054BD58A9C40@hxcore.ol> References: <255E7072-6B25-4AEC-BA89-054BD58A9C40@hxcore.ol> Message-ID: On 7/13/21 3:05 AM, rubiks solver wrote: > When I run python 3.9.6 on visual studio code it opens multiple python > setup windows. > > I rebooted my computer. Same result. > > > Is this a bug? No, it's a setup problem. Sounds like when you pointed Code at Python, you pointed it at the installer. You should be able to adjust it to point to the real Python executable. Unfortunately, since there are so many choices how things could have been installed from the various different sources, but a guess at the path you want would be something like: ...\AppData\Local\Programs\Python\Python39\python.exe From lucas at bourneuf.net Tue Jul 13 12:56:19 2021 From: lucas at bourneuf.net (lucas) Date: Tue, 13 Jul 2021 18:56:19 +0200 Subject: argparse support of/by argparse In-Reply-To: References: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> <8f7a5f6d-6b64-24ab-4140-1c83bd6a533b@bourneuf.net> Message-ID: Mmmh, that may work just fine ! Thanks for that idea, ChrisA, i'm looking forward to implement that. Best wishes, --lucas On 12/07/2021 21:33, Chris Angelico wrote: > On Tue, Jul 13, 2021 at 5:22 AM lucas wrote: >> >> Hello everyone, >> >> Let us consider this patch of code: >> >> import argparse >> >> def parse_cli() -> argparse.Namespace: >> parser = argparse.ArgumentParser() >> parser.add_argument('n', type=int) >> return parser.parse_args() >> >> args = parse_cli() >> print(args.n + ' ') # type error >> >> Running CPython on it will raise a TypeError, and running Mypy on it >> will indicate that no issues were found. >> >> I was wondering if there is any way for me to have mypy detecting the >> args.n type, based on the type keyword of the parser.add_argument function ? >> >> It appears that some type annotations were added to tierce party >> modules, provided by mypy itself. Is there a technical issue preventing >> such work to be made for argparse (or other CLI ; i didn't find anything >> for others either) >> > > Seems complicated, since it depends on a lot of run-time information. > What if you flip the problem on its head? Instead of creating the > argparser and letting that govern the types, maybe create a dataclass, > and then programmatically build the parser. > > from dataclasses import dataclass > import argparse > > @dataclass > class Args: > n: int > > def parse_cli() -> Args: > parser = argparse.ArgumentParser() > for field, typ in Args.__dataclass_fields__.items(): > if hasattr(typ, "type"): typ = typ.type # Python 3.10 changed > things a bit > parser.add_argument(field, type=typ) > return Args(**vars(parser.parse_args())) > > args = parse_cli() > print(args.n + ' ') > > > Only barely tested it and didn't try MyPy, but that's the basic idea. > You'd have to figure out the tidiest way to define all the other > attributes of your arguments (help text, etc), but ideally, all the > info should be able to be coded in the dataclass. > > Incidentally, you could choose to make parse_cli into a classmethod of > Args. Might be cleaner. > > ChrisA > From rshepard at appl-ecosys.com Tue Jul 13 16:24:48 2021 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 13 Jul 2021 13:24:48 -0700 (PDT) Subject: Tkinter widgets for desktop database application Message-ID: I'm writing a couple of database applications that use tkinter, and not a web browser, for the UI and I'm still trying to determine the optimal way to do this. Individual tk and ttk widgets (LineEntry, Combobox, etc.) work for adding and modifying individual database table rows but not for displaying multiple rows returned by a SELECT statement. To view all rows returned by the SQL statement would a pythonReport be used? I'm working on learning to use tksheet as the sole widget because it can display multiple rows from a database table as well as add new rows and modify existing ones (one or more columns in each row). What have other developers used for the UI on a stand-alone database application not using a web browser? I've struggled with finding the most efficient and optimal non-brower UI for months and would like to have a solid path toward a working solution. I know too little to make this decision and want advice, suggestions, and recommendations from experienced developers. TIA, Rich From loris.bennett at fu-berlin.de Wed Jul 14 01:54:30 2021 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Wed, 14 Jul 2021 07:54:30 +0200 Subject: Simple SSL client hangs References: <871r821wlg.fsf@hornfels.zedat.fu-berlin.de> <90db8099-786a-db88-9cff-6c15bd43d958@mrabarnett.plus.com> Message-ID: <87r1g1o2y1.fsf@hornfels.zedat.fu-berlin.de> Hi, MRAB writes: > On 2021-07-13 08:50, Loris Bennett wrote: >> Hi, >> >> In Perl I have the following >> >> use IO::Socket::SSL; >> >> my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere, >> PeerPort => 12345, >> ); >> >> my $line = <$my_socket>; >> print("$line\n"); >> say $my_socket 'ECHO 1'; >> $line = <$my_socket>; >> print("$line\n"); >> >> This runs as expected and I get >> >> 200 Some Server Somewhere - Hello [123.456.789.123] >> >> 310 Hello Echo >> >> If I try the same with the following Python code: >> >> import socket >> import ssl >> >> HOST = "some.server.somewhere" >> PORT = 12345 >> >> context = ssl.create_default_context() >> >> with socket.create_connection((HOST, PORT)) as sock: >> with context.wrap_socket(sock, server_hostname=HOST) as ssock: >> data = ssock.recv(1024) >> print(data.decode()) >> ssock.write(b'ECHO 1') >> data = ssock.read(1024) >> print(data.decode()) >> >> I get a timeout for the 'ECHO' command: >> >> 200 Some Server Somewhere - Hello [123.456.789.123] >> >> 501 Timeout >> >> Does anyone have an idea what I might be doing wrong? >> > The docs for Perl says that 'say' appends a newline. > > On the other hand, 'ssock.write' doesn't append a newline. > > Could that be the problem? Thanks and well-spotted everyone! The missing newline was indeed the problem. With ssock.write(b'ECHO 1\n') the Python codes behaves like the Perl code. Cheers, Loris -- This signature is currently under construction. From alan.gauld at yahoo.co.uk Wed Jul 14 03:54:12 2021 From: alan.gauld at yahoo.co.uk (Alan Gauld) Date: Wed, 14 Jul 2021 08:54:12 +0100 Subject: Tkinter widgets for desktop database application In-Reply-To: References: Message-ID: On 13/07/2021 21:24, Rich Shepard wrote: > What have other developers used for the UI on a stand-alone database > application not using a web browser? Mostly I just use a scrolledlistbox and a set of functions for formatting the data into columns for display. The big snag is you can't do spreadsheet-like things such as select a single field value or sort by a single column without writing a fair bit of code. But for simple display, and selection of a single record it works ok. But a good grid control would be nice. I did try to use the Tix.grid widget but failed. And now Tix is deprecated. I'm sure there must be a third-party one somewhere but I've never taken the time to hunt one down. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos From tjreedy at udel.edu Wed Jul 14 06:20:36 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 14 Jul 2021 06:20:36 -0400 Subject: Tkinter widgets for desktop database application In-Reply-To: References: Message-ID: On 7/13/2021 4:24 PM, Rich Shepard wrote: > I'm writing a couple of database applications that use tkinter, and not a > web browser, for the UI and I'm still trying to determine the optimal > way to > do this. > > Individual tk and ttk widgets (LineEntry, Combobox, etc.) work for adding Do you mean Entry? > and modifying individual database table rows but not for displaying > multiple > rows returned by a SELECT statement. To view all rows returned by the SQL > statement would a pythonReport be used? ttk.Treeview can be used for read-only hierarchical and table data. Search 'python ttk Treeview' and Images for examples. > I'm working on learning to use tksheet as the sole widget because it can > display multiple rows from a database table as well as add new rows and > modify existing ones (one or more columns in each row). I have not used it but have read some of manual and it seems suitable for editing flat table. -- Terry Jan Reedy From lizzyhollins99 at gmail.com Wed Jul 14 09:20:04 2021 From: lizzyhollins99 at gmail.com (Betty Hollinshead) Date: Wed, 14 Jul 2021 06:20:04 -0700 (PDT) Subject: Tkinter widgets for desktop database application In-Reply-To: References: Message-ID: <7169310e-018e-4abd-8fda-b827d2fec7cfn@googlegroups.com> On Tuesday, 13 July 2021 at 21:35:01 UTC+1, Rich Shepard wrote: > I'm writing a couple of database applications that use tkinter, and not a > web browser, for the UI and I'm still trying to determine the optimal way to > do this. > > Individual tk and ttk widgets (LineEntry, Combobox, etc.) work for adding > and modifying individual database table rows but not for displaying multiple > rows returned by a SELECT statement. To view all rows returned by the SQL > statement would a pythonReport be used? > > I'm working on learning to use tksheet as the sole widget because it can > display multiple rows from a database table as well as add new rows and > modify existing ones (one or more columns in each row). > > What have other developers used for the UI on a stand-alone database > application not using a web browser? I've struggled with finding the most > efficient and optimal non-brower UI for months and would like to have a > solid path toward a working solution. I know too little to make this > decision and want advice, suggestions, and recommendations from experienced > developers. > > TIA, > > Rich So.....I've had success with GTK3 (not Tkinter). Steps involve a non-Pythonic start: 1. Design your GUI with Glade. It's a GUI design tool for GUIs! Output is an XML definition tool which you import into your Python program. To your point about multiple lines, see the GTK TextView widget. 2. In Python: from gi.repository import GObject, Gio, Gdk, Gtk ... builder = Gtk.Builder.new_from_file("mainwin.xml") builder.connect_signals(self) ..... self.MainWindow1 = builder.get_object("window") ...... ......and the other GUI definitions from Glade/XML .......and so on......I've used this basic structure with the Python3 interface to SQLITE3 with success. Sorry about the paucity of the example.....it's a big subject....but there's lots of help out there! L. From rshepard at appl-ecosys.com Wed Jul 14 15:56:03 2021 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 14 Jul 2021 12:56:03 -0700 (PDT) Subject: Tkinter widgets for desktop database application In-Reply-To: <7169310e-018e-4abd-8fda-b827d2fec7cfn@googlegroups.com> References: <7169310e-018e-4abd-8fda-b827d2fec7cfn@googlegroups.com> Message-ID: On Wed, 14 Jul 2021, Betty Hollinshead wrote: > So.....I've had success with GTK3 (not Tkinter). Betty, There are multiple widget sets and all will work better with some application types than others. In the past I used wxPython but switched to Tkinter. Tried PyQt5 (doesn't do complex, multi-table queries like it does single table queries) and seriously considered GTK3. After all that time and effort I decided to stick with tkinter for two reasons: 1) I know it better than PyQt5 and 2) most users of one application I'm developing run Microsoft's OSes, some Apple. Since Tkinter comes with Python3 it's one less thing for non-techical users to struggle with if they decide to use this application. Thanks for your suggestion, Rich From drsalists at gmail.com Thu Jul 15 00:57:17 2021 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 14 Jul 2021 21:57:17 -0700 Subject: argparse support of/by argparse In-Reply-To: References: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> <8f7a5f6d-6b64-24ab-4140-1c83bd6a533b@bourneuf.net> Message-ID: On Mon, Jul 12, 2021 at 12:34 PM Chris Angelico wrote: > On Tue, Jul 13, 2021 at 5:22 AM lucas wrote: > > Running CPython on it will raise a TypeError, and running Mypy on it > > will indicate that no issues were found. > > > > I was wondering if there is any way for me to have mypy detecting the > > args.n type, based on the type keyword of the parser.add_argument > function ? > > > > It appears that some type annotations were added to tierce party > > modules, provided by mypy itself. Is there a technical issue preventing > > such work to be made for argparse (or other CLI ; i didn't find anything > > for others either) > > > > Seems complicated, since it depends on a lot of run-time information. > What if you flip the problem on its head? Instead of creating the > argparser and letting that govern the types, maybe create a dataclass, > and then programmatically build the parser. > This is why I eschew argparse. I instead frequently do something like: def usage(retval): """Output a usage message.""" if retval: write = sys.stderr.write else: write = sys.stdout.write write(f'{sys.argv[0]} --age 50 --help\n') sys.exit(retval) def main(): """Compute maximum heart rate as a function of age.""" age = -1 while sys.argv[1:]: if sys.argv[1] == '--age': age = float(sys.argv[2]) del sys.argv[1] elif sys.argv[1] in ('-h', '--help'): usage(0) else: sys.stderr.write(f'{sys.argv[0]}: unrecognized option: {sys.argv[1]}\n') usage(1) del sys.argv[1] if age == -1: sys.stderr.write('--age is a required option\n') usage(1) It is of course a little more typing, but tools like mypy and pylint are much more effective this way. This is a small program, but in a large one, this approach can really help with correctness. If someone has a mypy extension/plugin that can do argparse as well, I may switch. Until then.... From rosuav at gmail.com Thu Jul 15 01:11:37 2021 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 15 Jul 2021 15:11:37 +1000 Subject: argparse support of/by argparse In-Reply-To: References: <3d0141c4.AVcAADaD-x0AAAAAAAAAALKOdssAAYAyApsAAAAAAA4_9wBg7I_Z@mailjet.com> <8f7a5f6d-6b64-24ab-4140-1c83bd6a533b@bourneuf.net> Message-ID: On Thu, Jul 15, 2021 at 2:57 PM Dan Stromberg wrote: > > > On Mon, Jul 12, 2021 at 12:34 PM Chris Angelico wrote: >> >> On Tue, Jul 13, 2021 at 5:22 AM lucas wrote: >> > Running CPython on it will raise a TypeError, and running Mypy on it >> > will indicate that no issues were found. >> > >> > I was wondering if there is any way for me to have mypy detecting the >> > args.n type, based on the type keyword of the parser.add_argument function ? >> > >> > It appears that some type annotations were added to tierce party >> > modules, provided by mypy itself. Is there a technical issue preventing >> > such work to be made for argparse (or other CLI ; i didn't find anything >> > for others either) >> > >> >> Seems complicated, since it depends on a lot of run-time information. >> What if you flip the problem on its head? Instead of creating the >> argparser and letting that govern the types, maybe create a dataclass, >> and then programmatically build the parser. > > > This is why I eschew argparse. I instead frequently do something like: > > def usage(retval): > """Output a usage message.""" > if retval: > write = sys.stderr.write > else: > write = sys.stdout.write > > write(f'{sys.argv[0]} --age 50 --help\n') > > sys.exit(retval) > > > def main(): > """Compute maximum heart rate as a function of age.""" > age = -1 > while sys.argv[1:]: > if sys.argv[1] == '--age': > age = float(sys.argv[2]) > del sys.argv[1] > elif sys.argv[1] in ('-h', '--help'): > usage(0) > else: > sys.stderr.write(f'{sys.argv[0]}: unrecognized option: {sys.argv[1]}\n') > usage(1) > del sys.argv[1] > > if age == -1: > sys.stderr.write('--age is a required option\n') > usage(1) > > > It is of course a little more typing, but tools like mypy and pylint are much more effective this way. This is a small program, but in a large one, this approach can really help with correctness. > > If someone has a mypy extension/plugin that can do argparse as well, I may switch. Until then.... > The more complicated the program, the more you lose by this approach. Yes, mypy is satisfied with your code, but your argument parsing is more rigid and you don't get all the other benefits of argparse. Plus it's all too easy to make a copy and paste error, where you make a new parameter that accidentally puts its value into the same variable as an old parameter, or something. Much better to make a wrapper around argparse. I've made good use of clize [1], and have made ad-hoc wrappers for various purposes. Try adding mypy support to something like that instead - it's likely to be a lot easier. In fact, since clize primarily uses function arguments, it'd probably Just Work? for the most part, although I haven't tried. [1] https://pypi.org/project/clize/ ChrisA From mal at europython.eu Fri Jul 16 08:20:10 2021 From: mal at europython.eu (Marc-Andre Lemburg) Date: Fri, 16 Jul 2021 14:20:10 +0200 Subject: EuroPython 2021: Conference Organisers & Community Discounts Message-ID: <92be586d-bcbd-93a6-4926-70f267a7b4de@europython.eu> The EuroPython Society (EPS) exists not only to run the EuroPython Conference, but also to support the wider Python community in Europe. It accomplishes this in many ways; here are two of them! * EuroPython Society supporting the community * https://blog.europython.eu/europython-2021-conference-organizers-community-discounts/ Organisers' Lunch ----------------- We have an open invitation for organisers responsible for other Python conferences around Europe to attend lunch with us. The aim is for us all to get to know each other and share advice on running events, as well as determine how we, the EPS, can support other events. To enable this, we are offering one free conference ticket per conference team, to ensure that each event can send a representative. If you would like to avail of this, please email board at europython.eu to introduce yourselves, your event and the background of your team. The lunch is planned for the Thursday or Friday of the event, and finalised details will be announced closer to the conference. Community Discounts ------------------- In addition to the aforementioned lunch, we would also like to support individuals who attend conferences and smaller user groups around Europe. Although we cannot offer free tickets, we would like to offer discounted tickets to local communities. If you are a regular attendee to Python events, please direct your local organisers to this post; they may submit a request for this community discount, and will be responsible for distributing them to the people who attend their events. If you are responsible for organising Python events, please reach out to board at europython.eu in order to obtain a discount code for your attendees, encouraging them to engage with the global Python community. These discount codes will provide 10% off all ticket prices; they are intended for groups of 30-50 members, but we can provide codes for larger groups as long as this requirement is mentioned in your initial contact email. Quick Summary ------------- EuroPython 2021 will be run online from July 26 - August 1: - Two workshop/training days (July 26 - 27) - Three conference days (July 28 - 30) - Two sprint days (July 31 - August 1) The sessions will be scheduled to ensure they are also accessible for those in the Asian and Americas time zones. More infos are available on our website at https://ep2021.europython.eu/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-conference-organizers-community-discounts/ Tweet: https://twitter.com/europythons/status/1416007784332763140 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ From cl at isbd.net Sat Jul 17 08:01:50 2021 From: cl at isbd.net (Chris Green) Date: Sat, 17 Jul 2021 13:01:50 +0100 Subject: Searching pypi.org, is there an 'advanced search'? Message-ID: Every time I go to pypi.org to look for a neat utility or something I curse the stupid search. Is there really no better search available? Apart from anything else it appears to OR the elements together so, for example, I wanted to search for programs/libraries that will allow me to access Google Contacts:- Putting the words Google and Contacts in the search box produces more than 10000 hits. Putting just Google in the search box produces 8,629 projects. So, it would appear the terms are OR'ed together, surely OR'ing terms in a search (by default) went out with the ark! When I put 'Google contacts' in the search box I want projects that have both 'Google' AND 'Contacts' in their description somewhere! (... and, no, I tried 'Google AND Contacts', still more than 10000 results). pypi.org is a wonderful resource but its size now demands a better search engine. -- Chris Green ? From nospam at please.ty Sat Jul 17 18:53:24 2021 From: nospam at please.ty (jak) Date: Sun, 18 Jul 2021 00:53:24 +0200 Subject: packages discoverer Message-ID: Sometimes, wandering around the web, I find some example of python code that uses some class or function that I don't know and that I would like to try. I copy the code locally and when I try to run it, I find that the package containing the class/function is not installed on my pc, so I go back to the web to search for it with the search engine. The question is: is there a command or an easy way to find out the name of the package that contains the class/function of my interest? Thank you in advance. From avigross at verizon.net Sat Jul 17 21:29:41 2021 From: avigross at verizon.net (Avi Gross) Date: Sat, 17 Jul 2021 21:29:41 -0400 Subject: Searching pypi.org, is there an 'advanced search'? In-Reply-To: References: Message-ID: <023f01d77b74$62055b60$26101220$@verizon.net> Chris, Just a bit off topic, but google does have some advanced features such as using the word AND or putting something in quotes to make it search for the combination written the same way. Some of the tricks work for other search engines too. Google does have an advanced search feature here: https://www.google.com/advanced_search For example you may insist on ALL THESE WORDS for a page to be shown or words not to be on the page and more such as only find things on some web site. Good luck. I did such a search for having both google and contacts on just pypi.org and got only 2050 results! LOL! https://www.google.com/search?as_q=google+contacts&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=pypi.org&as_occt=any&safe=images&as_filetype=&tbs= -----Original Message----- From: Python-list On Behalf Of Chris Green Sent: Saturday, July 17, 2021 8:02 AM To: python-list at python.org Subject: Searching pypi.org, is there an 'advanced search'? Every time I go to pypi.org to look for a neat utility or something I curse the stupid search. Is there really no better search available? Apart from anything else it appears to OR the elements together so, for example, I wanted to search for programs/libraries that will allow me to access Google Contacts:- Putting the words Google and Contacts in the search box produces more than 10000 hits. Putting just Google in the search box produces 8,629 projects. So, it would appear the terms are OR'ed together, surely OR'ing terms in a search (by default) went out with the ark! When I put 'Google contacts' in the search box I want projects that have both 'Google' AND 'Contacts' in their description somewhere! (... and, no, I tried 'Google AND Contacts', still more than 10000 results). pypi.org is a wonderful resource but its size now demands a better search engine. -- Chris Green ? -- https://mail.python.org/mailman/listinfo/python-list From cs at cskk.id.au Sat Jul 17 21:35:18 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 18 Jul 2021 11:35:18 +1000 Subject: packages discoverer In-Reply-To: References: Message-ID: On 18Jul2021 00:53, jak wrote: >Sometimes, wandering around the web, I find some example of python code >that uses some class or function that I don't know and that I would like >to try. I copy the code locally and when I try to run it, I find that >the package containing the class/function is not installed on my pc, so >I go back to the web to search for it with the search engine. The >question is: is there a command or an easy way to find out the name of >the package that contains the class/function of my interest? Usually a third party package will be in PyPI: https://pypi.org/ If the import line of the unknown function looks like this: from package_name import function_name you should be able to search for it there. Or, of course: python -m pip install --user package_name to install it in your local Python environment, ready for use. Cheers, Cameron Simpson From python at mrabarnett.plus.com Sat Jul 17 21:40:21 2021 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 18 Jul 2021 02:40:21 +0100 Subject: Searching pypi.org, is there an 'advanced search'? In-Reply-To: References: Message-ID: <9688a221-e87f-52ba-0607-49fcaf07cf67@mrabarnett.plus.com> On 2021-07-17 13:01, Chris Green wrote: > Every time I go to pypi.org to look for a neat utility or something I > curse the stupid search. > > Is there really no better search available? Apart from anything else > it appears to OR the elements together so, for example, I wanted to > search for programs/libraries that will allow me to access Google > Contacts:- > > Putting the words Google and Contacts in the search box produces > more than 10000 hits. > > Putting just Google in the search box produces 8,629 projects. > > So, it would appear the terms are OR'ed together, surely OR'ing terms > in a search (by default) went out with the ark! > > When I put 'Google contacts' in the search box I want projects that > have both 'Google' AND 'Contacts' in their description somewhere! > (... and, no, I tried 'Google AND Contacts', still more than 10000 > results). > > pypi.org is a wonderful resource but its size now demands a better > search engine. > There's always Google. I find that the search terms: "google contacts" pypi finds some results. From __peter__ at web.de Sun Jul 18 03:48:15 2021 From: __peter__ at web.de (Peter Otten) Date: Sun, 18 Jul 2021 09:48:15 +0200 Subject: Searching pypi.org, is there an 'advanced search'? In-Reply-To: <9688a221-e87f-52ba-0607-49fcaf07cf67@mrabarnett.plus.com> References: <9688a221-e87f-52ba-0607-49fcaf07cf67@mrabarnett.plus.com> Message-ID: On 18/07/2021 03:40, MRAB wrote: > On 2021-07-17 13:01, Chris Green wrote: >> pypi.org is a wonderful resource but its size now demands a better >> search engine. >> > There's always Google. I find that the search terms: > > ??? "google contacts" pypi > > finds some results. With a small modification "google contacts" site:pypi.org the number of results goes down to 25 (of which 13 are shown by default). From cl at isbd.net Sun Jul 18 04:15:18 2021 From: cl at isbd.net (Chris Green) Date: Sun, 18 Jul 2021 09:15:18 +0100 Subject: Searching pypi.org, is there an 'advanced search'? References: <090def09-dbd2-45cb-aa87-79916305c5bdn@googlegroups.com> Message-ID: Mark Lawrence wrote: > On Saturday, July 17, 2021 at 1:03:21 PM UTC+1, Chris Green wrote: > > Every time I go to pypi.org to look for a neat utility or something I > > curse the stupid search. > > > > Is there really no better search available? Apart from anything else > > it appears to OR the elements together so, for example, I wanted to > > search for programs/libraries that will allow me to access Google > > Contacts:- > > > > Putting the words Google and Contacts in the search box produces > > more than 10000 hits. > > > > Putting just Google in the search box produces 8,629 projects. > > > > So, it would appear the terms are OR'ed together, surely OR'ing terms > > in a search (by default) went out with the ark! > > > > When I put 'Google contacts' in the search box I want projects that > > have both 'Google' AND 'Contacts' in their description somewhere! > > (... and, no, I tried 'Google AND Contacts', still more than 10000 > > results). > > > > pypi.org is a wonderful resource but its size now demands a better > > search engine. > > > > As this is an open source project I'm looking forward to the huge amount > of work that you personally will be putting in to remedy this situation. > In summary put up or shut up :) I'm quite happy to help, however I was just asking (maybe rather more agressively than I should have done) if I was missing something obvious. E.g. is there some syntax that I don't know about that I can use in the search box, or maybe I should use an external search engine? ... and Open Source doesn't mean one can't criticise surely, rather the opposite! :-) (I have, by the way, contributed in a minor way to quite a few open source projects over the years, and that's a lot of years! I even have a small credit in the 'bible' for the Kermit file transfer protocol, remember that?) -- Chris Green ? From cl at isbd.net Sun Jul 18 04:30:32 2021 From: cl at isbd.net (Chris Green) Date: Sun, 18 Jul 2021 09:30:32 +0100 Subject: Searching pypi.org, is there an 'advanced search'? References: <9688a221-e87f-52ba-0607-49fcaf07cf67@mrabarnett.plus.com> Message-ID: <8e5dsh-s4mq1.ln1@esprimo.zbmc.eu> Peter Otten <__peter__ at web.de> wrote: > On 18/07/2021 03:40, MRAB wrote: > > On 2021-07-17 13:01, Chris Green wrote: > > >> pypi.org is a wonderful resource but its size now demands a better > >> search engine. > >> > > There's always Google. I find that the search terms: > > > > ??? "google contacts" pypi > > > > finds some results. > > With a small modification > > "google contacts" site:pypi.org > > the number of results goes down to 25 (of which 13 are shown by default). > But of course that only finds places where the words "google contacts" occur together. I think I (OP) should probably try:- google contacts site:pypi.org I don't use Google but I tried it on my preferrred search engine (DuckDuckGo) and it produces rather more than 25 results but, as they're sorted (among other things) by the distance between the words 'google' and 'contacts' (I think) it produces the sort of result I was hoping for. Thanks all. -- Chris Green ? From christian at python.org Sun Jul 18 14:27:03 2021 From: christian at python.org (Christian Heimes) Date: Sun, 18 Jul 2021 20:27:03 +0200 Subject: Searching pypi.org, is there an 'advanced search'? In-Reply-To: References: <090def09-dbd2-45cb-aa87-79916305c5bdn@googlegroups.com> Message-ID: On 18/07/2021 10.15, Chris Green wrote: > Mark Lawrence wrote: >> On Saturday, July 17, 2021 at 1:03:21 PM UTC+1, Chris Green wrote: >>> Every time I go to pypi.org to look for a neat utility or something I >>> curse the stupid search. >>> >>> Is there really no better search available? Apart from anything else >>> it appears to OR the elements together so, for example, I wanted to >>> search for programs/libraries that will allow me to access Google >>> Contacts:- >>> >>> Putting the words Google and Contacts in the search box produces >>> more than 10000 hits. >>> >>> Putting just Google in the search box produces 8,629 projects. >>> >>> So, it would appear the terms are OR'ed together, surely OR'ing terms >>> in a search (by default) went out with the ark! >>> >>> When I put 'Google contacts' in the search box I want projects that >>> have both 'Google' AND 'Contacts' in their description somewhere! >>> (... and, no, I tried 'Google AND Contacts', still more than 10000 >>> results). >>> >>> pypi.org is a wonderful resource but its size now demands a better >>> search engine. >>> >> >> As this is an open source project I'm looking forward to the huge amount >> of work that you personally will be putting in to remedy this situation. >> In summary put up or shut up :) > > I'm quite happy to help, however I was just asking (maybe rather more > agressively than I should have done) if I was missing something > obvious. E.g. is there some syntax that I don't know about that I can > use in the search box, or maybe I should use an external search engine? > > ... and Open Source doesn't mean one can't criticise surely, rather > the opposite! :-) (I have, by the way, contributed in a minor way to > quite a few open source projects over the years, and that's a lot of > years! I even have a small credit in the 'bible' for the Kermit file > transfer protocol, remember that?) PyPI used to have a search API. The XML-RPC endpoints were disabled last year due to flooding. Our infrastructure could not cope with abusive queries. You can read the log of events at https://status.python.org/ Christian From tjreedy at udel.edu Sun Jul 18 19:44:13 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 18 Jul 2021 19:44:13 -0400 Subject: zoneinfo not working properly In-Reply-To: References: Message-ID: On 7/18/2021 1:44 AM, Shashank Jain wrote: > I was using python 3.9.3 then zoneinfo library was working fine without any > issues. but now after installing 3.9.6 there are problems. Ex. > > Using below code there no outputs. and further there are issues while > working with timezones with zoninfo where I tried same things with pytz > that was giving correct output. > > for i in zoneinfo.available_timezones(): > print(i) https://docs.python.org/3/library/zoneinfo.html#data-sources starts with "The zoneinfo module does not directly provide time zone data, and instead pulls time zone information from the system time zone database or the first-party PyPI package tzdata, if available." Somehow and for some reason, it is no longer getting the data. So I suggest reading the section to see if you can determine why. If 3.9.6 is a separate installation from the 3.9.3, rather than an upgrade thereof, then maybe you need to install tzdata for the new installation. Being on Windows, where this is not available, I cannot help further. -- Terry Jan Reedy From mal at europython.eu Mon Jul 19 07:00:25 2021 From: mal at europython.eu (Marc-Andre Lemburg) Date: Mon, 19 Jul 2021 13:00:25 +0200 Subject: EuroPython 2021: Keynotes and Booklet Message-ID: <0ea5ee50-edb6-2355-7dc2-7565f49545e4@europython.eu> EuroPython 2021 begins next week. We are proud to present the keynote speakers and our conference booklet. Keynotes -------- The following keynotes will take place on Wednesday, Thursday and Friday. Tickets are still available. If you want to find out more about our keynote speakers, please head on to the keynotes page on our website. https://ep2021.europython.eu/events/keynotes/ - Pablo Galindo Salgado: Nobody expects the Spanish inquisition In this talk I will go into some interesting stories of how (C)Python is made. We will go through a journey that will show you how Python is developed, who works on it, interesting battles against the most obscure of bugs and lots of unexpected situations and things to learn and to reflect on. - Abigail Dogbe: Python in a world of Pan-Africanism The use of Python in Africa is widely spread daily. In this talk, I will take you on a journey of what Python means to us in a Pan-African setting, lessons learned from organizing PyCon Africa, the people behind it, challenges we are facing and reflections on what works in our ecosystem. - Claudia Comito: Connecting Communities: the Helmholtz Analytics Framework and the making of Heat HPC, Scientific Big Data, co-design, Python: beneath the buzzwords, bringing together academics from the most disparate research fields to work on a common product is no easy feat. What worked, what didn't, and lessons learned from the Helmholtz Analytics Framework experience. - Dr. Kimberly Arcand: Our Universe through Sight, Sound & Touch Information of our Universe doesn't have to be just a two-dimensional snap shot. We can transform these data to be able to listen, feel, or (virtually) move through cosmic objects. Listen to the debris from an exploded star, walk through the core of our Milky Way in virtual reality, feel vibrations of a stellar nursery, and experience our universe anew. - David Beazley: No, not typing. Types. While biking through the forest preserve on a dark December morning, I found myself suddenly staring face-to-face with Bambi. Picking myself off the ground with a broken wrist and an assortment of broken fingers, I embarked on an unexpected journey of discovery. Then the pandemic hit. In this talk, I provide a trip report. - Joannah Nanjekye: Python the Bad Parts Python is great but it definitely has faults too.In this talk, I will talk about some of the Python challenges as a language, and the current efforts in the community to alleviate them. I will also talk about how I plan to engage scientists and academics during my time on the PSF board, to highlight some of the research we are working on as a community. Conference Booklet ------------------ Our designer Jessica has created a beautiful conference booklet for you to refer to during the conference and keep as a memory afterwards. It details all of the information regarding the schedule, talks, workshops and sponsors as a single PDF file. https://ep2021.europython.eu/events/conference-booklet/ Quick Summary ------------- EuroPython 2021 will be run online from July 26 - August 1: - Two workshop/training days (July 26 - 27) - Three conference days (July 28 - 30) - Two sprint days (July 31 - August 1) The sessions will be scheduled to ensure they are also accessible for those in the Asian and Americas time zones. More infos are available on our website at https://ep2021.europython.eu/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-keynotes-and-booklet/ Tweet: https://twitter.com/europythons/status/1417074329951641603 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ From Joseph.Schachner at Teledyne.com Mon Jul 19 12:59:40 2021 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Mon, 19 Jul 2021 16:59:40 +0000 Subject: Is there a conference in the US that is similar to EuroPython? Message-ID: I am not going to fly to Europe for a Python conference. But, would consider going if in the U.S.A. Especially if drivable ... NYC area would be ideal. I ask because I have seen ads for EuroPython over several years, and I don't remember seeing similar ads for something similar in the U.S.A. --- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data From larry.martell at gmail.com Mon Jul 19 13:06:35 2021 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 19 Jul 2021 10:06:35 -0700 Subject: Is there a conference in the US that is similar to EuroPython? In-Reply-To: References: Message-ID: On Mon, Jul 19, 2021 at 10:01 AM Schachner, Joseph wrote: > > I am not going to fly to Europe for a Python conference. But, would consider going if in the U.S.A. Especially if drivable ... NYC area would be ideal. > > I ask because I have seen ads for EuroPython over several years, and I don't remember seeing similar ads for something similar in the U.S.A. https://pycon.org/ From Bischoop at vimart.net Mon Jul 19 12:55:36 2021 From: Bischoop at vimart.net (Bischoop) Date: Mon, 19 Jul 2021 16:55:36 -0000 (UTC) Subject: Python for Android Message-ID: Will Python delevopment apps for Android OS getting easier? So far best option is Kivy which is not liked by many developers, another option is PyQT5, which finally gets some support but there still are some buts.. Tkinter, some tried but it's still a NO for Android support. From MikeE at ster.invalid Mon Jul 19 13:21:29 2021 From: MikeE at ster.invalid (Mike Easter) Date: Mon, 19 Jul 2021 10:21:29 -0700 Subject: XAMPP control panel python Message-ID: I don't do any programming, including python. I've encountered a python situation which I'm wondering would be a huge task to remedy or not. XAMPP is a package of programs which is installed to linux w/ an install .run file from apache friends. There is an associated xampp-control-panel.py file which is apparently derived from an xampp-control-panel.glade file, both in the opt/lampp/ share/xampp-control-panel dir. Apparently this CP feature of xampp is not maintained (files dated 2009) and the 2009 CP readme says: To run the XAMPP Control Panel, you will need: Linux (may work on other OSs) GTK 2.x PyGTK (also known as python-gtk) 2.x XAMPP I installed py2 to my Linux Mint Cinnamon 20.2 (off Ub LTS 20.04) but that didn't solve the problem w/ running the .py file w/ python2; I got a traceback saying there was no gtk module. The pip I have is for py3. I can put the .py file on pastebin if anyone wants. Apparently the Win v. of xampp has a CP based on Delphi someone said, so that one is being maintained. -- Mike Easter From akkana at shallowsky.com Mon Jul 19 14:44:15 2021 From: akkana at shallowsky.com (Akkana Peck) Date: Mon, 19 Jul 2021 12:44:15 -0600 Subject: XAMPP control panel python In-Reply-To: References: Message-ID: <20210719184415.GA6548@shallowsky.com> Mike Easter writes: > the CP readme says: > > To run the XAMPP Control Panel, you will need: > > Linux (may work on other OSs) > GTK 2.x > PyGTK (also known as python-gtk) 2.x > XAMPP > > I installed py2 to my Linux Mint Cinnamon 20.2 (off Ub LTS 20.04) but that > didn't solve the problem w/ running the .py file w/ python2; I got a > traceback saying there was no gtk module. The pip I have is for py3. I can > put the .py file on pastebin if anyone wants. Unfortunately python-gtk has been dropped from the last few Ubuntu releases. I assume Mint must have followed suit. Nobody seems to know why they dropped python-gtk while keeping other python2 packages. Pip2 wouldn't have helped you; the pip version of python-gtk didn't build on Linux even back when python2 was still supported. The place where this gets the most discussion is the GIMP community, so it may help to add gimp to your web search terms, e.g. search on gimp python2 mint ppa and you'll find lots of discussions on how to get python-gtk. There are various repositories that still maintain builds of python-gtk: for instance, see https://ubuntuhandbook.org/index.php/2020/07/ppa-install-gimp-2-10-20-ubuntu-20-04/ or the python-gtk2_2.24.0-5 packages at http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/pygtk/ Good luck! ...Akkana From mal at europython.eu Tue Jul 20 06:31:31 2021 From: mal at europython.eu (Marc-Andre Lemburg) Date: Tue, 20 Jul 2021 12:31:31 +0200 Subject: EuroPython 2021: Full-Day Workshops Message-ID: <33ed33fe-77fc-bcab-d6e4-80248da1e490@europython.eu> This year's edition of EuroPython begins with two days of training sessions as outlined in the schedule. Many of these last 3 hours, however, we would like to highlight two specific workshops available to those who want a deeper dive. They are most valuable for people new to the Python language and ecosystem, and focus on different things. Django Girls Workshop --------------------- Returning for another year, Django Girls will be running a workshop that will teach you how to build your own blog from scratch over the course of the day. Attendees will be split into small groups, and there are no special requirements! The Django Girls Workshop is scheduled on Monday, July 26th, starting at 09:30 CEST (07:30 UTC). Registration for this workshop is handled via application on their website, which details the criteria they look for in applicants. https://djangogirls.org/nottingham/apply/ Read on to learn more about the workshop and Django Girls. https://ep2021.europython.eu/events/django-girls/ Beginners' Day Workshop ----------------------- There is also another workshop facilitated by Humble Data, serving as an introduction to how Python is used in the data science community. This also has no special requirements, and attendees will similarly be working in small, focused groups. The Beginners? Day Workshop run by Humble Data is scheduled for Tuesday, July 27, starting at 09:30 CEST (07:30 UTC). Attendance is free for conference and combined ticket holders. Read on to learn more about the workshop and Humble Data. https://ep2021.europython.eu/events/beginners-day/ Quick Summary ------------- EuroPython 2021 will be run online from July 26 - August 1: - Two workshop/training days (July 26 - 27) - Three conference days (July 28 - 30) - Two sprint days (July 31 - August 1) The sessions will be scheduled to ensure they are also accessible for those in the Asian and Americas time zones. More infos are available on our website at https://ep2021.europython.eu/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-full-day-workshops/ Tweet: https://twitter.com/europython/status/1417430600932380698 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ From ethan at stoneleaf.us Wed Jul 21 17:09:30 2021 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 21 Jul 2021 14:09:30 -0700 Subject: RFC for PEP 663: Improving and Standardizing Enum str(), repr(), and format() behaviors Message-ID: PEP: 663 Title: Improving and Standardizing Enum str(), repr(), and format() behaviors Version: $Revision$ Last-Modified: $Date$ Author: Ethan Furman Discussions-To: python-dev at python.org Status: Draft Type: Informational Content-Type: text/x-rst Created: 23-Feb-2013 Python-Version: 3.11 Post-History: 20-Jul-2021 Resolution: Abstract ======== Now that we have a few years experience with Enum usage it is time to update the ``repr()``, ``str()``, and ``format()`` of the various enumerations by their intended purpose. Motivation ========== The addition of ``StrEnum`` with its requirement to have its ``str()`` be its ``value`` is inconsistent with other provided Enum's ``str``. Having the ``str()`` of ``IntEnum`` and ``IntFlag`` not be the value causes bugs and extra work when replacing existing constants. Having the ``str()`` and ``format()`` of an enum member be different can be confusing. The iteration of ``Flag`` members, which directly affects their ``repr()``, is inelegant at best, and buggy at worst. Rationale ========= Enums are becoming more common in the standard library; being able to recognize enum members by their ``repr()``, and having that ``repr()`` be easy to parse, is useful and can save time and effort in understanding and debugging code. However, the enums with mixed-in data types (``IntEnum``, ``IntFlag``, and the new ``StrEnum``) need to be more backwards compatible with the constants they are replacing -- specifically, ``str(replacement_enum_member) == str(original_constant)`` should be true (and the same for ``format()``). IntEnum, IntFlag, and StrEnum should be as close to a drop-in replacement of existing integer and string constants as is possible. Towards that goal, the str() output of each should be its inherent value; e.g. if ``Color`` is an ``IntEnum``:: >>> Color.RED >>> str(Color.RED) '1' >>> format(Color.RED) '1' Note that format() already produces the correct output in 3.10, only str() needs updating. As much as possible, the ``str()`, ``repr()``, and ``format()`` of enum members should be standardized across the stardard library. The repr() of Flag currently includes aliases, which it should not; fixing that will, of course, already change its ``repr()`` in certain cases. Specification ============= There a three broad categories of enum usage: - standard: Enum or Flag a new enum class is created, and the members are used as ``class.member_name`` - drop-in replacement: IntEnum, IntFlag, StrEnum a new enum class is created which also subclasses ``int`` or ``str`` and uses ``int.__str__`` or ``str.__str__``; the ``repr`` can be changed by using the ``global_enum`` decorator - user-mixed enums and flags the user creates their own integer-, float-, str-, whatever-enums instead of using enum.IntEnum, etc. Some sample enums:: # module: tools.py class Hue(Enum): # or IntEnum LIGHT = -1 NORMAL = 0 DARK = +1 class Color(Flag): # or IntFlag RED = 1 GREEN = 2 BLUE = 4 class Grey(int, Enum): # or (int, Flag) BLACK = 0 WHITE = 1 Using the above enumerations, the following table shows the old and new behavior, while the last shows the final result: +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | type | enum repr() | enum str() | enum format() | flag repr() | flag str() | flag format() | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | standard | 3.10 | | | | | Color.RED|GREEN | Color.RED|GREEN | | +----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | | new | | | | | Color.RED|Color.GREEN | Color.RED|Color.GREEN | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | user mixed | 3.10 | | | 1 | | | 1 | | +----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | | new | | | Grey.WHITE | | | Grey.WHITE | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | int drop-in | 3.10 | | Hue.LIGHT | | | Color.RED|GREEN | | | +----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | | new | | -1 | | | 3 | | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | global | 3.10 | | Hue.LIGHT | Hue.LIGHT | | Color.RED|GREEN | Color.RED|GREEN | | +----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | | new | tools.LIGHT | LIGHT | LIGHT | tools.RED|tools.GREEN | RED|GREEN | RED|GREEN | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | user mixed | 3.10 | | Grey.WHITE | 1 | | +----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | | new | tools.WHITE | WHITE | WHITE | tools.WHITE | WHITE | WHITE | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | int drop-in | 3.10 | | Hue.LIGHT | | | Color.RED|GREEN | | | +----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | | new | tools.LIGHT | -1 | | tools.RED|tools.GREEN | 3 | | +-------------+----------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ Which will result in: +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | type | enum repr() | enum str() | enum format() | flag repr() | flag str() | flag format() | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | standard | | Hue.LIGHT | Hue.LIGHT | | Color.RED|Color.GREEN | Color.RED|Color.GREEN | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | user mixed | | Grey.WHITE | Grey.WHITE | | Grey.WHITE | Grey.WHITE | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | int drop-in | | -1 | -1 | | 3 | 3 | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | global | tools.LIGHT | LIGHT | LIGHT | tools.RED|tools.GREEN | RED|GREEN | RED|GREEN | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | user mixed | tools.WHITE | WHITE | WHITE | tools.WHITE | WHITE | WHITE | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ | int drop-in | tools.LIGHT | -1 | -1 | tools.RED|tools.GREEN | 3 | 3 | +-------------+-----------------+------------+-----------------------+-----------------------+------------------------+-----------------------+ As can be seen, ``repr()`` is primarily affected by whether the members are global, while ``str()`` is affected by being global or by being a drop-in replacement, with the drop-in replacement status having a higher priority. Also, the basic ``repr()`` and ``str()`` have changed for flags as the old style was very clunky. The ``repr()`` for Enum vs Flag are different, primarily because the Enum ``repr()`` does not work well for flags. I like being able to tell whether an enum member is a Flag or an Enum based on the ``repr()`` alone, but am open to arguments for changing Enum's ``repr()`` to match Flag's. Backwards Compatibility ======================= My understanding is that ``str()`` and ``repr()`` output has much lower backwards compatibility requirements. Even so, I expect the majority of breakage to be in doc and unit tests. I'm less clear on the policy for ``format()``. Note that by changing the ``str()`` of the drop-in category, we will actually prevent future breakage when ``IntEnum``, et al, are used to replace existing constants. Mitigation ========== Normal usage of enum members will not change: ``re.ASCII`` can still be used as ``re.ASCII`` and will still compare equal to ``256``. If one wants their own enums in their own code to remain the same they will need to write their own base Enum class and then write the appropriate ``repr``, ``str()``, and ``format()`` methods (or copy them from the 3.10 enum module). Copyright ========= This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive. From mal at europython.eu Thu Jul 22 04:38:02 2021 From: mal at europython.eu (Marc-Andre Lemburg) Date: Thu, 22 Jul 2021 10:38:02 +0200 Subject: EuroPython 2021: Data Science Mini-Conference Message-ID: It has become a tradition at EuroPython to include a special data science track. * EuroPython 2021 Data Science Mini-Conference * https://ep2021.europython.eu/events/data-science/ This year, we have expanded on the theme and included more data science related content than ever before, including keynotes and workshops -- our own EuroPython Data Science mini-conference which includes: - 37 Talks - 9 Workshops - 2 Keynotes - 2 Interactive Sessions - one Poster Tickets are still available through our online shop and will be throughout next week. https://ep2021.europython.eu/registration/buy-tickets/ Data Science Keynotes --------------------- We? would like like to highlight our data science keynotes on Thursday: Claudia Comito: Connecting Communities: the Helmholtz Analytics Framework and the making of Heat HPC, Scientific Big Data, co-design, Python: beneath the buzzwords, bringing together academics from the most disparate research fields to work on a common product is no easy feat. What worked, what didn't, and lessons learned from the Helmholtz Analytics Framework experience. Dr. Kimberly Arcand: Our Universe through Sight, Sound & Touch Information of our Universe doesn't have to be just a two-dimensional snap shot. We can transform these data to be able to listen, feel, or (virtually) move through cosmic objects. Listen to the debris from an exploded star, walk through the core of our Milky Way in virtual reality, feel vibrations of a stellar nursery, and experience our universe anew. For full information, please check our Data Science @ EuroPython 2021 page, which lists the complete data science program: https://ep2021.europython.eu/events/data-science/ Access to the data science parts of the conference is part of our regular conference tickets. If you want to participate in the data science content, please obtain a combined ticket. Quick Summary ------------- EuroPython 2021 will be run online from July 26 - August 1: - Two workshop/training days (July 26 - 27) - Three conference days (July 28 - 30) - Two sprint days (July 31 - August 1) The sessions will be scheduled to ensure they are also accessible for those in the Asian and Americas time zones. More infos are available on our website at https://ep2021.europython.eu/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-data-science-mini-conference/ Tweet: https://twitter.com/europython/status/1418125300811145221 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ From barry at barrys-emacs.org Thu Jul 22 08:33:29 2021 From: barry at barrys-emacs.org (Barry) Date: Thu, 22 Jul 2021 13:33:29 +0100 Subject: Python for Android Message-ID: <7B6A8F91-98E1-4B92-9D00-006BB3328948@barrys-emacs.org> ? > On 19 Jul 2021, at 18:43, Bischoop wrote: > > ? > Will Python delevopment apps for Android OS getting easier? > So far best option is Kivy which is not liked by many developers, > another option is PyQT5, which finally gets some support but there still > are some buts.. > Tkinter, some tried but it's still a NO for Android support. Buts? My understanding is the PyQt5 has good support for Android. I have not personal used that support, but I have used PyQt5 for none trivial projects on Linux, macOs and windows and like it. > -- > https://mail.python.org/mailman/listinfo/python-list From taco.sea.open at gmail.com Thu Jul 22 20:24:15 2021 From: taco.sea.open at gmail.com (=?UTF-8?B?44Gf44GT44GX44Gf44GT44GX?=) Date: Fri, 23 Jul 2021 09:24:15 +0900 Subject: help me please. "install reppy" Message-ID: I get an error so please help. I don't know what to do. Windows 10 Python 3.9.6 from takashi in Japan -------------- next part -------------- Microsoft Windows [Version 10.0.19042.1110] (c) Microsoft Corporation. All rights reserved. C:\Users\user>pip3 install reppy Looking in indexes: https://pypi.python.org/simple/ Collecting reppy Using cached reppy-0.4.14.tar.gz (93 kB) Requirement already satisfied: cachetools in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from reppy) (4.2.2) Requirement already satisfied: python-dateutil!=2.0,>=1.5 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from reppy) (2.8.1) Requirement already satisfied: requests in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from reppy) (2.25.1) Requirement already satisfied: six in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from reppy) (1.16.0) Requirement already satisfied: idna<3,>=2.5 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests->reppy) (2.10) Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests->reppy) (2021.5.30) Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests->reppy) (4.0.0) Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (from requests->reppy) (1.26.6) Building wheels for collected packages: reppy Building wheel for reppy (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'c:\users\user\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjlk_02k\\reppy_2f114414e650471d8c3902d5b364a96c\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjlk_02k\\reppy_2f114414e650471d8c3902d5b364a96c\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\user\AppData\Local\Temp\pip-wheel-pcr61ilh' cwd: C:\Users\user\AppData\Local\Temp\pip-install-sjlk_02k\reppy_2f114414e650471d8c3902d5b364a96c\ Complete output (69 lines): Building from C++ c:\users\user\appdata\local\programs\python\python39\lib\site-packages\setuptools\dist.py:697: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.9 creating build\lib.win-amd64-3.9\reppy copying reppy\exceptions.py -> build\lib.win-amd64-3.9\reppy copying reppy\ttl.py -> build\lib.win-amd64-3.9\reppy copying reppy\util.py -> build\lib.win-amd64-3.9\reppy copying reppy\__init__.py -> build\lib.win-amd64-3.9\reppy creating build\lib.win-amd64-3.9\reppy\cache copying reppy\cache\policy.py -> build\lib.win-amd64-3.9\reppy\cache copying reppy\cache\__init__.py -> build\lib.win-amd64-3.9\reppy\cache running build_ext building 'reppy.robots' extension creating build\temp.win-amd64-3.9 creating build\temp.win-amd64-3.9\Release creating build\temp.win-amd64-3.9\Release\reppy creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\deps creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\deps\url-cpp creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\deps\url-cpp\src creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\src C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/psl.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/psl.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? psl.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/punycode.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/punycode.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? punycode.cpp reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(64): warning C4267: '+=': 'size_t' ?? 'Url::Punycode::punycode_uint' ?????????????????????????? reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(113): warning C4267: '??': 'size_t' ?? 'Url::Punycode::punycode_uint' ?????????????????? ???????? reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(299): warning C4267: '??': 'size_t' ?? 'Url::Punycode::punycode_uint' ?????????????????? ???????? reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(306): warning C4267: '+=': 'size_t' ?? 'Url::Punycode::punycode_uint' ??????????????????? ??????? C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/url.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/url.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? url.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/utf8.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/utf8.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? utf8.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/src/agent.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/src/agent.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? agent.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/src/directive.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/src/directive.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? directive.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/src/robots.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/src/robots.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? robots.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/robots.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/robots.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? robots.cpp reppy/robots.cpp(7788): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7796): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7805): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7814): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7822): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7828): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(9108): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3 reppy/robots.cpp(9124): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3 error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 ---------------------------------------- ERROR: Failed building wheel for reppy Running setup.py clean for reppy Failed to build reppy Installing collected packages: reppy Running setup.py install for reppy ... error ERROR: Command errored out with exit status 1: command: 'c:\users\user\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjlk_02k\\reppy_2f114414e650471d8c3902d5b364a96c\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjlk_02k\\reppy_2f114414e650471d8c3902d5b364a96c\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user\AppData\Local\Temp\pip-record-ms5enyge\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\user\appdata\local\programs\python\python39\Include\reppy' cwd: C:\Users\user\AppData\Local\Temp\pip-install-sjlk_02k\reppy_2f114414e650471d8c3902d5b364a96c\ Complete output (69 lines): Building from C++ c:\users\user\appdata\local\programs\python\python39\lib\site-packages\setuptools\dist.py:697: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running install running build running build_py creating build creating build\lib.win-amd64-3.9 creating build\lib.win-amd64-3.9\reppy copying reppy\exceptions.py -> build\lib.win-amd64-3.9\reppy copying reppy\ttl.py -> build\lib.win-amd64-3.9\reppy copying reppy\util.py -> build\lib.win-amd64-3.9\reppy copying reppy\__init__.py -> build\lib.win-amd64-3.9\reppy creating build\lib.win-amd64-3.9\reppy\cache copying reppy\cache\policy.py -> build\lib.win-amd64-3.9\reppy\cache copying reppy\cache\__init__.py -> build\lib.win-amd64-3.9\reppy\cache running build_ext building 'reppy.robots' extension creating build\temp.win-amd64-3.9 creating build\temp.win-amd64-3.9\Release creating build\temp.win-amd64-3.9\Release\reppy creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\deps creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\deps\url-cpp creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\deps\url-cpp\src creating build\temp.win-amd64-3.9\Release\reppy\rep-cpp\src C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/psl.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/psl.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? psl.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/punycode.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/punycode.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? punycode.cpp reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(64): warning C4267: '+=': 'size_t' ?? 'Url::Punycode::punycode_uint' ?????????????????????????? reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(113): warning C4267: '??': 'size_t' ?? 'Url::Punycode::punycode_uint' ????????????????? ????????? reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(299): warning C4267: '??': 'size_t' ?? 'Url::Punycode::punycode_uint' ????????????????? ????????? reppy/rep-cpp/deps/url-cpp/src/punycode.cpp(306): warning C4267: '+=': 'size_t' ?? 'Url::Punycode::punycode_uint' ?????????????????? ???????? C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/url.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/url.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? url.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/deps/url-cpp/src/utf8.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/deps/url-cpp/src/utf8.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? utf8.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/src/agent.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/src/agent.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? agent.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/src/directive.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/src/directive.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? directive.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/rep-cpp/src/robots.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/rep-cpp/src/robots.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? robots.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ireppy/rep-cpp/include -Ireppy/rep-cpp/deps/url-cpp/include -Ic:\users\user\appdata\local\programs\python\python39\include -Ic:\users\user\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpreppy/robots.cpp /Fobuild\temp.win-amd64-3.9\Release\reppy/robots.obj -std=c++11 cl : ???? ??? warning D9002 : ???????? '-std=c++11' ??????? robots.cpp reppy/robots.cpp(7788): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7796): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7805): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7814): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7822): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(7828): error C2039: 'tp_print': '_typeobject' ???????????? c:\users\user\appdata\local\programs\python\python39\include\cpython/object.h(193): note: '_typeobject' ???????????? reppy/robots.cpp(9108): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3 reppy/robots.cpp(9124): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3 error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\users\user\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjlk_02k\\reppy_2f114414e650471d8c3902d5b364a96c\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjlk_02k\\reppy_2f114414e650471d8c3902d5b364a96c\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user\AppData\Local\Temp\pip-record-ms5enyge\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\user\appdata\local\programs\python\python39\Include\reppy' Check the logs for full command output. C:\Users\user> From uri at speedy.net Fri Jul 23 00:54:27 2021 From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=) Date: Fri, 23 Jul 2021 07:54:27 +0300 Subject: Python and Ubuntu versions Message-ID: Hi, I have a production server with Ubuntu 18.04 LTS (currently upgraded to Ubuntu 18.04.5 LTS) and I use Python in virtualenv - currently Python 3.6.9. I'm using Django and I read that from Django 4.0, a minimal version of Python 3.8 will be required. I would like to know how I use the latest version of Python (3.10 or 3.9) with my production server - do I have to reinstall a new server with the latest Ubuntu LTS version? Or do I have to upgrade my current server's Ubuntu version by upgrading the same machine? Or should I keep the Ubuntu version and only upgrade Python? I'm also using other software such as PostgreSQL which is currently psql (PostgreSQL) 10.17 (Ubuntu 10.17-0ubuntu0.18.04.1). Should I upgrade this too? And what is the risk that things will not work after I upgrade this? Thanks, ???? uri at speedy.net From jdevries3133 at gmail.com Thu Jul 22 23:34:02 2021 From: jdevries3133 at gmail.com (Jack DeVries) Date: Thu, 22 Jul 2021 23:34:02 -0400 Subject: help me please. "install reppy" In-Reply-To: References: Message-ID: See here for a discussion around this issue: https://github.com/seomoz/reppy/issues/90 This project requires a C++ build environment to be setup on your computer. The fact that your compiler is reporting that `std=c++11` as an unknown option shows that you don't have a C++ build environment set up. As you will see, at the end of the issue above, they link to this issue: https://github.com/Benny-/Yahoo-ticker-symbol-downloader/issues/46 In that second issue, a user reports: > hey all. I solved the issue by installing Build tools for visual c++ 2015 (v14). The link does not work. > You have to look for build tools for visual studio 2017 (v15) and look at the options in the installer. As a side note, you might consider using this robots.txt parser from the standard library instead. It's already installed and ready to go, and doesn't use very-overkill C++ dependencies! Good luck! On Thu, Jul 22, 2021 at 8:44 PM ?????? wrote: > I get an error so please help. > I don't know what to do. > > Windows 10 > Python 3.9.6 > > from takashi in Japan > -- > https://mail.python.org/mailman/listinfo/python-list > From jdevries3133 at gmail.com Thu Jul 22 23:34:46 2021 From: jdevries3133 at gmail.com (Jack DeVries) Date: Thu, 22 Jul 2021 23:34:46 -0400 Subject: help me please. "install reppy" In-Reply-To: References: Message-ID: Oops, forgot the link to the standard library robots.txt parser. Here are the docs! https://docs.python.org/3/library/urllib.robotparser.html *sorry for the noise* On Thu, Jul 22, 2021 at 11:34 PM Jack DeVries wrote: > See here for a discussion around this issue: > https://github.com/seomoz/reppy/issues/90 > > This project requires a C++ build environment to be setup on your > computer. The fact that your compiler is reporting that `std=c++11` as an > unknown option shows that you don't have a C++ build environment set up. As > you will see, at the end of the issue above, they link to this issue: > > https://github.com/Benny-/Yahoo-ticker-symbol-downloader/issues/46 > > In that second issue, a user reports: > > hey all. I solved the issue by installing Build tools for visual c++ > 2015 (v14). The link does not work. > > You have to look for build tools for visual studio 2017 (v15) and look > at the options in the installer. > > As a side note, you might consider using this robots.txt parser from the > standard library instead. It's already installed and ready to go, and > doesn't use very-overkill C++ dependencies! > > Good luck! > > > On Thu, Jul 22, 2021 at 8:44 PM ?????? wrote: > >> I get an error so please help. >> I don't know what to do. >> >> Windows 10 >> Python 3.9.6 >> >> from takashi in Japan >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From sjeik_appie at hotmail.com Fri Jul 23 03:34:02 2021 From: sjeik_appie at hotmail.com (Albert-Jan Roskam) Date: Fri, 23 Jul 2021 09:34:02 +0200 Subject: argparse support of/by argparse In-Reply-To: Message-ID: >>> [1] https://pypi.org/project/clize/ I use and like docopt (https://github.com/docopt/docopt). Is clize a better choice? From rosuav at gmail.com Fri Jul 23 03:41:50 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Jul 2021 17:41:50 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: ?On Fri, Jul 23, 2021 at 2:55 PM ??????? wrote:? > > Hi, > > I have a production server with Ubuntu 18.04 LTS (currently upgraded to > Ubuntu 18.04.5 LTS) and I use Python in virtualenv - currently Python > 3.6.9. I'm using Django and I read that from Django 4.0, a minimal version > of Python 3.8 will be required. I would like to know how I use the latest > version of Python (3.10 or 3.9) with my production server - do I have to > reinstall a new server with the latest Ubuntu LTS version? Or do I have to > upgrade my current server's Ubuntu version by upgrading the same machine? > Or should I keep the Ubuntu version and only upgrade Python? I'm also using > other software such as PostgreSQL which is currently psql (PostgreSQL) > 10.17 (Ubuntu 10.17-0ubuntu0.18.04.1). Should I upgrade this too? And what > is the risk that things will not work after I upgrade this? > It's probably easiest to build Python from source. Clone the source repository from GitHub, and build it right there. You can then upgrade your venv to use it, reinstall packages, and everything should work. ChrisA From rosuav at gmail.com Fri Jul 23 03:42:43 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Jul 2021 17:42:43 +1000 Subject: argparse support of/by argparse In-Reply-To: References: Message-ID: On Fri, Jul 23, 2021 at 5:34 PM Albert-Jan Roskam wrote: > > >>> [1] https://pypi.org/project/clize/ > > > I use and like docopt (https://github.com/docopt/docopt). Is clize a better choice? > Not necessarily. Both are good. Explore both, see which one makes more sense. ChrisA From brgl at bgdev.pl Fri Jul 23 04:20:06 2021 From: brgl at bgdev.pl (Bartosz Golaszewski) Date: Fri, 23 Jul 2021 10:20:06 +0200 Subject: Defining a Python enum in a C extension - am I doing this right? Message-ID: Hi! I'm working on a Python C extension and I would like to expose a custom enum (as in: a class inheriting from enum.Enum) that would be entirely defined in C. It turned out to not be a trivial task and the regular mechanism for inheritance using .tp_base doesn't work - most likely due to the Enum's meta class not being pulled in. Basically I'm trying to do this: import enum class FooBar(enum.Enum): FOO = 1 BAR = 2 in C. After a lot of digging into cpython's internals, this is what I came up with, wrapped in an example buildable module: #include PyDoc_STRVAR(module_doc, "C extension module defining a class inheriting from enum.Enum."); static PyModuleDef module_def = { PyModuleDef_HEAD_INIT, .m_name = "pycenum", .m_doc = module_doc, .m_size = -1, }; struct enum_descr { const char *name; long value; }; static const struct enum_descr foobar_descr[] = { { .name = "FOO", .value = 1, }, { .name = "BAR", .value = 2, }, { } }; static PyObject *make_bases(PyObject *enum_mod) { PyObject *enum_type, *bases; enum_type = PyObject_GetAttrString(enum_mod, "Enum"); if (!enum_type) return NULL; bases = PyTuple_Pack(1, enum_type); /* Steals reference. */ if (!bases) Py_DECREF(enum_type); return bases; } static PyObject *make_classdict(PyObject *enum_mod, PyObject *bases) { PyObject *enum_meta_type, *classdict; enum_meta_type = PyObject_GetAttrString(enum_mod, "EnumMeta"); if (!enum_meta_type) return NULL; classdict = PyObject_CallMethod(enum_meta_type, "__prepare__", "sO", "FooBarEnum", bases); Py_DECREF(enum_meta_type); return classdict; } static int fill_classdict(PyObject *classdict, PyObject *modname, const struct enum_descr *descr) { const struct enum_descr *entry; PyObject *key, *val; int ret; key = PyUnicode_FromString("__module__"); if (!key) return -1; ret = PyObject_SetItem(classdict, key, modname); Py_DECREF(key); if (ret < 0) return -1; for (entry = descr; entry->name; entry++) { key = PyUnicode_FromString(entry->name); if (!key) return -1; val = PyLong_FromLong(entry->value); if (!val) { Py_DECREF(key); return -1; } ret = PyObject_SetItem(classdict, key, val); Py_DECREF(key); Py_DECREF(val); if (ret < 0) return -1; } return 0; } static PyObject *make_new_type(PyObject *classdict, PyObject *bases, const char *enum_name) { PyObject *name, *args, *new_type; int ret; name = PyUnicode_FromString(enum_name); if (!name) return NULL; args = PyTuple_Pack(3, name, bases, classdict); if (!args) { Py_DECREF(name); return NULL; } Py_INCREF(bases); Py_INCREF(classdict); /* * Reference to name was stolen by PyTuple_Pack(), no need to * increase it here. */ new_type = PyObject_CallObject((PyObject *)&PyType_Type, args); Py_DECREF(args); if (!new_type) return NULL; ret = PyType_Ready((PyTypeObject *)new_type); if (ret < 0) { Py_DECREF(new_type); return NULL; } return new_type; } static PyObject *make_enum_type(PyObject *modname, const char *enum_name, const struct enum_descr *descr) { PyObject *enum_mod, *bases, *classdict, *new_type; int ret; enum_mod = PyImport_ImportModule("enum"); if (!enum_mod) return NULL; bases = make_bases(enum_mod); if (!bases) { Py_DECREF(enum_mod); return NULL; } classdict = make_classdict(enum_mod, bases); if (!classdict) { Py_DECREF(bases); Py_DECREF(enum_mod); return NULL; } ret = fill_classdict(classdict, modname, descr); if (ret < 0) { Py_DECREF(bases); Py_DECREF(enum_mod); Py_DECREF(classdict); return NULL; } new_type = make_new_type(classdict, bases, enum_name); Py_DECREF(bases); Py_DECREF(enum_mod); Py_DECREF(classdict); return new_type; } PyMODINIT_FUNC PyInit_pycenum(void) { PyObject *module, *modname, *sub_enum_type; int ret; module = PyModule_Create(&module_def); if (!module) return NULL; ret = PyModule_AddStringConstant(module, "__version__", "0.0.1"); if (ret < 0) { Py_DECREF(module); return NULL; } modname = PyModule_GetNameObject(module); if (!modname) { Py_DECREF(module); return NULL; } sub_enum_type = make_enum_type(modname, "FooBar", foobar_descr); Py_DECREF(modname); if (!sub_enum_type) { Py_DECREF(module); return NULL; } ret = PyModule_AddObject(module, "FooBar", sub_enum_type); if (ret < 0) { Py_DECREF(sub_enum_type); Py_DECREF(module); return NULL; } return module; } Basically I'm calling the EnumMeta's __prepare__ method directly to create a correct classdict and then I call the PyType_Type object too to create the sub-type. This works and AFAICT results in a class that behaves exactly as expected, but... am I doing this right? Any feedback is appreciated. I want to use this in a real project, namely the v2 of libgpiod python bindings[1] so it's important to me to get this right. Best regards, Bartosz Golaszewski [1] https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ From cs at cskk.id.au Fri Jul 23 01:17:59 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 23 Jul 2021 15:17:59 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On 23Jul2021 07:54, ???? wrote: >I have a production server with Ubuntu 18.04 LTS (currently upgraded to >Ubuntu 18.04.5 LTS) and I use Python in virtualenv - currently Python >3.6.9. I'm using Django and I read that from Django 4.0, a minimal version >of Python 3.8 will be required. I would like to know how I use the latest >version of Python (3.10 or 3.9) with my production server - do I have to >reinstall a new server with the latest Ubuntu LTS version? Or do I have to >upgrade my current server's Ubuntu version by upgrading the same machine? >Or should I keep the Ubuntu version and only upgrade Python? I'm also using >other software such as PostgreSQL which is currently psql (PostgreSQL) >10.17 (Ubuntu 10.17-0ubuntu0.18.04.1). Should I upgrade this too? And what >is the risk that things will not work after I upgrade this? I would install a totally separate Python from the vendor (ubunut) provided one. This prevents subtle changes to what the OS has been tested against. You can built Python from source and install it, for example with a prefix like /usr/local/ptyhon-3.10. That gets you a different version; nothing in the OS stuff will try to use it, but you use it to invoke your Django app. Both Python and PostgreSQL tend to be very forward compatible - your code should not need to change. By making a separate install you're avoiding breaking OS stuff. Do the build and install as yourself. I usually do the install step by making the install directory as root, then chowning it to me. Then you can do the install as you - this has the advantage the you're unprivileged and can't accidentally damage the OS install. If you're just doing this for personal use then you can of course just install it in your own home directory, not root owned steps required at all. Cheers, Cameron Simpson From rosuav at gmail.com Fri Jul 23 05:51:53 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Jul 2021 19:51:53 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On Fri, Jul 23, 2021 at 7:48 PM Cameron Simpson wrote: > Do the build and install as yourself. I usually do the install step by > making the install directory as root, then chowning it to me. Then you > can do the install as you - this has the advantage the you're > unprivileged and can't accidentally damage the OS install. That's interesting, in that it leaves you vulnerable to accidentally damaging your alternate installation, but you're putting it into a directory that normally would look privileged. I'd be inclined to leave /usr as a privileged directory, and do this sort of installation entirely within ~/bin or something equivalent. But hey, this is the flexibility of Unix file system permissions! ChrisA From python at mrabarnett.plus.com Fri Jul 23 11:03:03 2021 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 23 Jul 2021 16:03:03 +0100 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: On 2021-07-23 09:20, Bartosz Golaszewski wrote: > Hi! > > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. > > It turned out to not be a trivial task and the regular mechanism for > inheritance using .tp_base doesn't work - most likely due to the > Enum's meta class not being pulled in. > > Basically I'm trying to do this: > [snip] > > static PyObject *make_bases(PyObject *enum_mod) > { > PyObject *enum_type, *bases; > > enum_type = PyObject_GetAttrString(enum_mod, "Enum"); > if (!enum_type) > return NULL; > > bases = PyTuple_Pack(1, enum_type); /* Steals reference. */ PyTuple_Pack doesn't steal references, as far as I can tell. > if (!bases) > Py_DECREF(enum_type); > > return bases; > } > [snip] From brgl at bgdev.pl Fri Jul 23 13:26:58 2021 From: brgl at bgdev.pl (Bartosz Golaszewski) Date: Fri, 23 Jul 2021 19:26:58 +0200 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: On Fri, Jul 23, 2021 at 5:08 PM MRAB wrote: > > On 2021-07-23 09:20, Bartosz Golaszewski wrote: > > Hi! > > > > I'm working on a Python C extension and I would like to expose a > > custom enum (as in: a class inheriting from enum.Enum) that would be > > entirely defined in C. > > > > It turned out to not be a trivial task and the regular mechanism for > > inheritance using .tp_base doesn't work - most likely due to the > > Enum's meta class not being pulled in. > > > > Basically I'm trying to do this: > > > [snip] > > > > static PyObject *make_bases(PyObject *enum_mod) > > { > > PyObject *enum_type, *bases; > > > > enum_type = PyObject_GetAttrString(enum_mod, "Enum"); > > if (!enum_type) > > return NULL; > > > > bases = PyTuple_Pack(1, enum_type); /* Steals reference. */ > > PyTuple_Pack doesn't steal references, as far as I can tell. > Right, the doc says it's equivalent to Py_BuildValue("(OO...)", ...) and it does increase the reference count on stored objects. It doesn't answer the main question though. :) Bartosz > > if (!bases) > > Py_DECREF(enum_type); > > > > return bases; > > } > > > [snip] > -- > https://mail.python.org/mailman/listinfo/python-list From nospam at please.ty Fri Jul 23 04:55:12 2021 From: nospam at please.ty (jak) Date: Fri, 23 Jul 2021 10:55:12 +0200 Subject: a clean exit Message-ID: Hello everybody, I wrote a bot for telegram which consists of some processes of which the main ones are: - the main process: a list of callback functions - a second process: managed with a message queue - a third process: started by the library I use (python-telegram-bot) which is used for the event/error log ('logging' module). The problem is that sometimes I get an error from the library (python- telegram-bot) via logging that my bot has no way of intercepting. The error is "connection reset by pear" after which my program is no longer called and I need to restart it. Typically this happens when Telegram runs an update. In any case I can know this error because, to write a log in a telegram channel, I inherit the 'emit' function of the 'logging.Handler' class. Hoping to have explained clearly enough the context in which the program receives information about the error (we are inside a process not launched directly from the main program), my question is: do you have advice on how I can close my program in the way as clean as possible in a easy way? Thanks in advance. From cl at isbd.net Fri Jul 23 06:33:48 2021 From: cl at isbd.net (Chris Green) Date: Fri, 23 Jul 2021 11:33:48 +0100 Subject: Where to keep local Python modules? Message-ID: This isn't a question about how to set PYTHONPATH so that Python code can find imported modules, it's about what is a sensible layout for one's home directory - i.e. where to put Python modules. I'm running Linux and have a number of Python modules that are only used by my own code. My top level Python code is all in ~/bin. I'd prefer to separate the modules so that they don't clutter the name space. Currently I have my Python modules in a subdirectory of ~/bin and my Python path is set as:- PYTHONPATH=/home/chris/bin/pymods Is this a reasonable approach? Is there a 'standard' name for the directory containing modules, or a standard place for it? (I don't mean a system-wide standard place, I mean a 'my' standard place). -- Chris Green ? From roland.em0001 at googlemail.com Fri Jul 23 15:46:04 2021 From: roland.em0001 at googlemail.com (Roland Mueller) Date: Fri, 23 Jul 2021 22:46:04 +0300 Subject: Where to keep local Python modules? In-Reply-To: References: Message-ID: Hello, pe 23. hein?k. 2021 klo 21.44 Chris Green (cl at isbd.net) kirjoitti: > This isn't a question about how to set PYTHONPATH so that Python code > can find imported modules, it's about what is a sensible layout for > one's home directory - i.e. where to put Python modules. > > I'm running Linux and have a number of Python modules that are only > used by my own code. My top level Python code is all in ~/bin. I'd > prefer to separate the modules so that they don't clutter the name > space. > > Currently I have my Python modules in a subdirectory of ~/bin and my > Python path is set as:- > > PYTHONPATH=/home/chris/bin/pymods > > Is this a reasonable approach? Is there a 'standard' name for the > directory containing modules, or a standard place for it? (I don't > mean a system-wide standard place, I mean a 'my' standard place). > > Under recent Linux distros there is $HOME/.local/ containing bin and lib directories. May be it's ok to use this for user-specific python settings under Linux. E.g. in .bashrc export PYTHONPATH=$HOME/.local/python Result can be checked then in Python: python >>> import sys >>> sys.path ['', '/home/someuser/.local/lib/python', '/usr/lib64/python39.zip', '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages', '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] BR, Roland > > -- > Chris Green > ? > -- > https://mail.python.org/mailman/listinfo/python-list > From pbryan at anode.ca Fri Jul 23 16:04:54 2021 From: pbryan at anode.ca (Paul Bryan) Date: Fri, 23 Jul 2021 13:04:54 -0700 Subject: Where to keep local Python modules? In-Reply-To: References: Message-ID: <19e23831cf92c1886bde36e43ca2c7c70322145e.camel@anode.ca> On my Arch Linux box, slightly different path, but still in .local/bin: pbryan at dynamo:~$ python3 Python 3.9.6 (default, Jun 30 2021, 10:22:16) [GCC 11.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/pbryan/.local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] >>> On Fri, 2021-07-23 at 22:46 +0300, Roland Mueller via Python-list wrote: > Hello, > > pe 23. hein?k. 2021 klo 21.44 Chris Green (cl at isbd.net) kirjoitti: > > > This isn't a question about how to set PYTHONPATH so that Python > > code > > can find imported modules, it's about what is a sensible layout for > > one's home directory - i.e. where to put Python modules. > > > > I'm running Linux and have a number of Python modules that are only > > used by my own code.? My top level Python code is all in ~/bin.? > > I'd > > prefer to separate the modules so that they don't clutter the name > > space. > > > > Currently I have my Python modules in a subdirectory of ~/bin and > > my > > Python path is set as:- > > > > ??? PYTHONPATH=/home/chris/bin/pymods > > > > Is this a reasonable approach?? Is there a 'standard' name for the > > directory containing modules, or a standard place for it?? (I don't > > mean a system-wide standard place, I mean a 'my' standard place). > > > > Under recent Linux distros there is $HOME/.local/ containing bin > > and lib > directories. May be it's ok to use this for user-specific python > settings > under Linux. > > E.g. in .bashrc > export PYTHONPATH=$HOME/.local/python > > Result can be checked then in Python: > python > > > > import sys > > > > sys.path > ['', '/home/someuser/.local/lib/python', '/usr/lib64/python39.zip', > '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', > '/usr/local/lib/python3.9/site-packages', > '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site- > packages'] > > BR, > Roland > > > > > > > > -- > > Chris Green > > ? > > -- > > https://mail.python.org/mailman/listinfo/python-list > > From tjreedy at udel.edu Fri Jul 23 16:40:58 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 23 Jul 2021 16:40:58 -0400 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On 7/23/2021 12:54 AM, ???? wrote: > Hi, > > I have a production server with Ubuntu 18.04 LTS (currently upgraded to > Ubuntu 18.04.5 LTS) and I use Python in virtualenv - currently Python > 3.6.9. I'm using Django and I read that from Django 4.0, a minimal version > of Python 3.8 will be required. I would like to know how I use the latest > version of Python (3.10 or 3.9) with my production server - do I have to 3.9 is the latest production release. Others packages should all be available. 3.10 is still in beta, and updated versions of some packages will not be available for a few months after its release in Sept. -- Terry Jan Reedy From cl at isbd.net Fri Jul 23 16:05:02 2021 From: cl at isbd.net (Chris Green) Date: Fri, 23 Jul 2021 21:05:02 +0100 Subject: Where to keep local Python modules? References: Message-ID: Roland Mueller wrote: > Hello, > > pe 23. hein?k. 2021 klo 21.44 Chris Green (cl at isbd.net) kirjoitti: > > > This isn't a question about how to set PYTHONPATH so that Python code > > can find imported modules, it's about what is a sensible layout for > > one's home directory - i.e. where to put Python modules. > > > > I'm running Linux and have a number of Python modules that are only > > used by my own code. My top level Python code is all in ~/bin. I'd > > prefer to separate the modules so that they don't clutter the name > > space. > > > > Currently I have my Python modules in a subdirectory of ~/bin and my > > Python path is set as:- > > > > PYTHONPATH=/home/chris/bin/pymods > > > > Is this a reasonable approach? Is there a 'standard' name for the > > directory containing modules, or a standard place for it? (I don't > > mean a system-wide standard place, I mean a 'my' standard place). > > > > Under recent Linux distros there is $HOME/.local/ containing bin and lib > directories. May be it's ok to use this for user-specific python settings > under Linux. > > E.g. in .bashrc > export PYTHONPATH=$HOME/.local/python > > Result can be checked then in Python: > python > >>> import sys > >>> sys.path > ['', '/home/someuser/.local/lib/python', '/usr/lib64/python39.zip', > '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', > '/usr/local/lib/python3.9/site-packages', > '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] > That's certainly a possibility, thanks. -- Chris Green ? From cs at cskk.id.au Fri Jul 23 18:51:32 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 24 Jul 2021 08:51:32 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On 23Jul2021 19:51, Chris Angelico wrote: >On Fri, Jul 23, 2021 at 7:48 PM Cameron Simpson wrote: >> Do the build and install as yourself. I usually do the install step by >> making the install directory as root, then chowning it to me. Then you >> can do the install as you - this has the advantage the you're >> unprivileged and can't accidentally damage the OS install. > >That's interesting, in that it leaves you vulnerable to accidentally >damaging your alternate installation, but you're putting it into a >directory that normally would look privileged. I'd be inclined to >leave /usr as a privileged directory, and do this sort of installation >entirely within ~/bin or something equivalent. But hey, this is the >flexibility of Unix file system permissions! Rereading this, maybe I was unclear. This is for install directories like /opt/Python-3.whatever or /usr/local/python-3.whatever. Create the install point, chown, install as yourself. I agree about the risk of future mangling - there's a good case for chowning it all to root _after_ the install. I'm just trying to do the install itself in an unprivileged mode. Probably for the OP, the simplest way is a local install as themselved, eg in ~/opt/python-3.whatever. Not rootneed needed at all, and a few symlinks in ~/bin (or adding ~/opt/python-3.whatever/bin to $PATH) are all that's needed to make use of it. Cheers, Cameron Simpson From cs at cskk.id.au Fri Jul 23 19:04:48 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 24 Jul 2021 09:04:48 +1000 Subject: Where to keep local Python modules? In-Reply-To: References: Message-ID: On 23Jul2021 11:33, Chris Green wrote: >This isn't a question about how to set PYTHONPATH so that Python code >can find imported modules, it's about what is a sensible layout for >one's home directory - i.e. where to put Python modules. > >I'm running Linux and have a number of Python modules that are only >used by my own code. My top level Python code is all in ~/bin. I'd >prefer to separate the modules so that they don't clutter the name >space. > >Currently I have my Python modules in a subdirectory of ~/bin and my >Python path is set as:- > > PYTHONPATH=/home/chris/bin/pymods > >Is this a reasonable approach? Is there a 'standard' name for the >directory containing modules, or a standard place for it? (I don't >mean a system-wide standard place, I mean a 'my' standard place). I don't know if this is sensible, but here is what I do. I use virtualenvs. By default I keep these in ~/var/venv. Here's my local MacOS: % ls -la ~/var/venv/ total 0 drwxr-xr-x 9 cameron cameron 288 1 Mar 19:47 . drwx--S--- 41 cameron cameron 1312 24 Jul 08:27 .. lrwxrwxr-x 1 cameron cameron 14 1 Mar 19:47 3 -> 3.9.2-homebrew drwxrwxr-x 8 cameron cameron 256 14 Jun 2020 3.7.7-homebrew drwxrwxr-x 6 cameron cameron 192 16 Aug 2020 3.8.5-hggit drwxrwxr-x 8 cameron cameron 256 23 Jul 2020 3.8.5-homebrew drwxrwxr-x 8 cameron cameron 256 21 Nov 2020 3.8.6-homebrew drwxrwxr-x 8 cameron cameron 256 28 Dec 2020 3.9.1_2-homebrew drwxrwxr-x 9 cameron cameron 288 26 May 15:17 3.9.2-homebrew I get my default Pythons from homebrew (again, because I'm on a Mac). So the Python came this way: % brew install python at 3.9 and the virtualenv got made like this: % python3.9 -m venv ~/var/venv/3.9.2-homebrew giving it a nice detailed directory name. I keep the convenience symlink "3" pointing at the preferred venv (usually the latest). Then I have ~/var/venv/3/bin in my $PATH. With that near the front of $PATH so that "python3" and "pip3" come from there, modules are installed with pip3, eg: % pip3 install cs.upd They land in the venv, and "python3" (which comes from the venv) knows to find them automatically. Almost everything I use comes either from pip or from my own modules. My $PYTHONPATH on the Mac has this: /Users/cameron/lib/python:/Users/cameron/rc/python being, respectively, my personal modules and a place for third party modules which do not come from pip. That latter is an empty set, but it's there. I doubt you'd need to bother with the latter; I doubt I need to either. Cheers, Cameron Simpson From rosuav at gmail.com Fri Jul 23 19:22:04 2021 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 24 Jul 2021 09:22:04 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On Sat, Jul 24, 2021 at 9:03 AM Cameron Simpson wrote: > > On 23Jul2021 19:51, Chris Angelico wrote: > >On Fri, Jul 23, 2021 at 7:48 PM Cameron Simpson wrote: > >> Do the build and install as yourself. I usually do the install step by > >> making the install directory as root, then chowning it to me. Then you > >> can do the install as you - this has the advantage the you're > >> unprivileged and can't accidentally damage the OS install. > > > >That's interesting, in that it leaves you vulnerable to accidentally > >damaging your alternate installation, but you're putting it into a > >directory that normally would look privileged. I'd be inclined to > >leave /usr as a privileged directory, and do this sort of installation > >entirely within ~/bin or something equivalent. But hey, this is the > >flexibility of Unix file system permissions! > > Rereading this, maybe I was unclear. This is for install directories > like /opt/Python-3.whatever or /usr/local/python-3.whatever. Create the > install point, chown, install as yourself. > > I agree about the risk of future mangling - there's a good case for > chowning it all to root _after_ the install. I'm just trying to do the > install itself in an unprivileged mode. Ah, I see what you mean. In that case, it's probably fine, but I'd just take the simpler approach and "sudo make install" (or altinstall as the case may be). > Probably for the OP, the simplest way is a local install as themselved, > eg in ~/opt/python-3.whatever. Not rootneed needed at all, and a few > symlinks in ~/bin (or adding ~/opt/python-3.whatever/bin to $PATH) are > all that's needed to make use of it. > Yeah, exactly. ChrisA From cs at cskk.id.au Fri Jul 23 19:35:28 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 24 Jul 2021 09:35:28 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On 24Jul2021 09:22, Chris Angelico wrote: >On Sat, Jul 24, 2021 at 9:03 AM Cameron Simpson wrote: >> Rereading this, maybe I was unclear. This is for install directories >> like /opt/Python-3.whatever or /usr/local/python-3.whatever. Create the >> install point, chown, install as yourself. >> >> I agree about the risk of future mangling - there's a good case for >> chowning it all to root _after_ the install. I'm just trying to do the >> install itself in an unprivileged mode. > >Ah, I see what you mean. In that case, it's probably fine, but I'd >just take the simpler approach and "sudo make install" (or altinstall >as the case may be). Ah, but to me this is the moral equivalent of: wget random-install-script-url | sh Ideally I'd be doing the install, and arguably the build, as a third user, neither root (keep the system intact) nor myself (my data! mine! don't you touch it!) >> Probably for the OP, the simplest way is a local install as themselved, >> eg in ~/opt/python-3.whatever. Not rootneed needed at all, and a few >> symlinks in ~/bin (or adding ~/opt/python-3.whatever/bin to $PATH) are >> all that's needed to make use of it. > >Yeah, exactly. Aye. But they seemed to be on the route of installing over the system Python, and I was trying to talk them down to just a "system wide but off to the side" install. Cheers, Cameron Simpson From rosuav at gmail.com Fri Jul 23 19:58:15 2021 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 24 Jul 2021 09:58:15 +1000 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On Sat, Jul 24, 2021 at 9:52 AM Cameron Simpson wrote: > > On 24Jul2021 09:22, Chris Angelico wrote: > >On Sat, Jul 24, 2021 at 9:03 AM Cameron Simpson wrote: > >> Rereading this, maybe I was unclear. This is for install directories > >> like /opt/Python-3.whatever or /usr/local/python-3.whatever. Create the > >> install point, chown, install as yourself. > >> > >> I agree about the risk of future mangling - there's a good case for > >> chowning it all to root _after_ the install. I'm just trying to do the > >> install itself in an unprivileged mode. > > > >Ah, I see what you mean. In that case, it's probably fine, but I'd > >just take the simpler approach and "sudo make install" (or altinstall > >as the case may be). > > Ah, but to me this is the moral equivalent of: > > wget random-install-script-url | sh Ehhh, it's not nearly that bad. The biggest risk with the wget command is that, even if you fully trust the source, all it takes is one small network issue and you're running a half a script. > Ideally I'd be doing the install, and arguably the build, as a third > user, neither root (keep the system intact) nor myself (my data! mine! > don't you touch it!) Oh, definitely the build is done as a non-root user. (I usually do that as my own user for simplicity, though.) And while I can see the benefits to installing as a dedicated separate user, it's also just way too fiddly, so I just sudo it and do things the easy way :) (That is, assuming I'm installing into /usr. If it's installed outside of those sorts of directories, then root won't be involved at all - for instance, if I'm developing OBS Studio, I'll build it into ~/tmp/obs/bin and its friends, and it'll all be done as my own user.) > >> Probably for the OP, the simplest way is a local install as themselved, > >> eg in ~/opt/python-3.whatever. Not rootneed needed at all, and a few > >> symlinks in ~/bin (or adding ~/opt/python-3.whatever/bin to $PATH) are > >> all that's needed to make use of it. > > > >Yeah, exactly. > > Aye. > > But they seemed to be on the route of installing over the system Python, > and I was trying to talk them down to just a "system wide but off to the > side" install. > Fair enough. And I absolutely agree with NOT installing over the system Python, although that's usually not going to happen anyway (since this is a different minor version). ChrisA From drsalists at gmail.com Sat Jul 24 00:55:34 2021 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 23 Jul 2021 21:55:34 -0700 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: On Fri, Jul 23, 2021 at 1:20 AM Bartosz Golaszewski wrote: > Hi! > > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. > I'm probably missing something obvious, but why would you write new code in C when you can just use Cython? Cython is a lot easier, and quite fast, and should (eventually?) allow compiling to HPY instead of just "the" C extension module interface. https://news.ycombinator.com/item?id=26627683 From dieter at handshake.de Sat Jul 24 13:53:14 2021 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 24 Jul 2021 19:53:14 +0200 Subject: a clean exit In-Reply-To: References: Message-ID: <24828.21386.791294.913732@ixdm.fritz.box> jak wrote at 2021-7-23 10:55 +0200: > ... >The problem is that sometimes I get an error from the library (python- >telegram-bot) via logging that my bot has no way of intercepting. The >error is "connection reset by pear" after which my program is no longer >called and I need to restart it. Typically this happens when Telegram >runs an update. "Connection reset by peer" means that the other end of the connection (the so called "peer") has closed the connection. You will need to open a new connection (as the old one can no longer be used). From cl at isbd.net Sat Jul 24 04:52:23 2021 From: cl at isbd.net (Chris Green) Date: Sat, 24 Jul 2021 09:52:23 +0100 Subject: Where to keep local Python modules? References: Message-ID: <7v0tsh-gp0q2.ln1@esprimo.zbmc.eu> Cameron Simpson wrote: > > Almost everything I use comes either from pip or from my own modules. My > $PYTHONPATH on the Mac has this: > > /Users/cameron/lib/python:/Users/cameron/rc/python > > being, respectively, my personal modules and a place for third party > modules which do not come from pip. That latter is an empty set, but > it's there. I doubt you'd need to bother with the latter; I doubt I need > to either. > Yes, I think maybe something in a 'lib' directory somewhere makes sense. I like to keep my home directory as uncluttered as possible though so maybe I'll keep the lib directory under ~/.config or ~/.local. -- Chris Green ? From MikeE at ster.invalid Fri Jul 23 17:11:35 2021 From: MikeE at ster.invalid (Mike Easter) Date: Fri, 23 Jul 2021 14:11:35 -0700 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: For those who are following this thread on a conventional news server, there are missing parts which came from the python-list mailing list instead. For those who prefer an nntp access to the mailing list, the corresponding group on news.gmane.io is gmane.comp.python.general. Posting there is unconventional. -- Mike Easter From tjreedy at udel.edu Sat Jul 24 15:22:04 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 24 Jul 2021 15:22:04 -0400 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: On 7/23/2021 5:11 PM, Mike Easter wrote: > For those who are following this thread on a conventional news server, > there are missing parts which came from the python-list mailing list > instead. > > For those who prefer an nntp access to the mailing list, the > corresponding group on news.gmane.io is gmane.comp.python.general. > > Posting there is unconventional. Huh? If you read this, posting from gmane works fine! -- Terry Jan Reedy From MikeE at ster.invalid Sat Jul 24 17:57:20 2021 From: MikeE at ster.invalid (Mike Easter) Date: Sat, 24 Jul 2021 14:57:20 -0700 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: Terry Reedy wrote: > Mike Easter wrote: >> For those who are following this thread on a conventional news server, >> there are missing parts which came from the python-list mailing list >> instead. >> >> For those who prefer an nntp access to the mailing list, the >> corresponding group on news.gmane.io is gmane.comp.python.general. >> >> Posting there is unconventional. > > Huh?? If you read this, posting from gmane works fine! > In the past, old gmane required posting w/ a good email because the gmane server required you to receive an email and self-approve your posting. So, are you saying that gmane didn't require you to approve/authorize your msg? I was able to read your msg on both gmane's and my conventional nntp. I replied on my conventional NIN because my typical config (and my config on the experimental gmane acct) was w/ a bogus/invalid email, and previously an accidental attempt to post on gmane that way failed. -- Mike Easter From MikeE at ster.invalid Sat Jul 24 18:04:23 2021 From: MikeE at ster.invalid (Mike Easter) Date: Sat, 24 Jul 2021 15:04:23 -0700 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: Mike Easter wrote: > Terry Reedy wrote: >> Mike Easter wrote: >>> For those who are following this thread on a conventional news >>> server, there are missing parts which came from the python-list >>> mailing list instead. >>> >>> For those who prefer an nntp access to the mailing list, the >>> corresponding group on news.gmane.io is gmane.comp.python.general. >>> >>> Posting there is unconventional. >> >> Huh?? If you read this, posting from gmane works fine! >> > In the past, old gmane required posting w/ a good email because the > gmane server required you to receive an email and self-approve your > posting. > > So, are you saying that gmane didn't require you to approve/authorize > your msg? > > I was able to read your msg on both gmane's and my conventional nntp.? I > replied on my conventional NIN because my typical config (and my config > on the experimental gmane acct) was w/ a bogus/invalid email, and > previously an accidental attempt to post on gmane that way failed. > I'm reading a msg that suggests that if you a sub/ed to the py-list, that takes care of the gmane 'unconventional' problem. -- Mike Easter From MikeE at ster.invalid Sat Jul 24 18:53:20 2021 From: MikeE at ster.invalid (Mike Easter) Date: Sat, 24 Jul 2021 15:53:20 -0700 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: Mike Easter wrote: > In the past, old gmane required posting w/ a good email because the > gmane server required you to receive an email and self-approve your > posting. The old gmane also obfuscated the email of someone posting that way. So, you needed to configure your agent to use a good email, but gmane used a strategy to mitigate exposing your email to spam. -- Mike Easter From uri at speedy.net Sun Jul 25 21:56:53 2021 From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=) Date: Mon, 26 Jul 2021 04:56:53 +0300 Subject: Python and Ubuntu versions In-Reply-To: References: Message-ID: Thank you. ???? uri at speedy.net On Sun, Jul 25, 2021 at 2:20 PM Mike Easter wrote: > Mike Easter wrote: > > In the past, old gmane required posting w/ a good email because the > > gmane server required you to receive an email and self-approve your > > posting. > > The old gmane also obfuscated the email of someone posting that way. > So, you needed to configure your agent to use a good email, but gmane > used a strategy to mitigate exposing your email to spam. > > -- > Mike Easter > -- > https://mail.python.org/mailman/listinfo/python-list > From brgl at bgdev.pl Mon Jul 26 03:28:04 2021 From: brgl at bgdev.pl (Bartosz Golaszewski) Date: Mon, 26 Jul 2021 09:28:04 +0200 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: On Sat, Jul 24, 2021 at 6:55 AM Dan Stromberg wrote: > > > On Fri, Jul 23, 2021 at 1:20 AM Bartosz Golaszewski wrote: >> >> Hi! >> >> I'm working on a Python C extension and I would like to expose a >> custom enum (as in: a class inheriting from enum.Enum) that would be >> entirely defined in C. > > > I'm probably missing something obvious, but why would you write new code in C when you can just use Cython? Cython is a lot easier, and quite fast, and should (eventually?) allow compiling to HPY instead of just "the" C extension module interface. > > https://news.ycombinator.com/item?id=26627683 > I'm the author and maintainer of libgpiod - the user-space library and tools for using the linux GPIO character device. The core library is written in C but we're also exposing C++ and Python bindings (with more language bindings planned). The python bindings are written as a C extension module and look like this: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/bindings/python/gpiodmodule.c. We're in the process of writing the (backward incompatible) version 2 of the library in order to support the new kernel features and the C API has changed a lot so we're also rewriting the bindings. Among others: all bitwise flags have now been converted to enums, hence my question. In C++ we'll use scoped enum classes and I'd like to do a similar thing in python. What I'm doing is not aimed at using C for speed but for calling the C APIs. I know I could use SWIG but in order to make the interface elegant, it would have to be packaged in proper Python classes anyway, creating another layer of code so I prefer to just use C. Bart From filters24 at yahoo.com Mon Jul 26 18:19:58 2021 From: filters24 at yahoo.com (Glenn Wilson) Date: Mon, 26 Jul 2021 22:19:58 +0000 (UTC) Subject: a simple question References: <1760081237.825858.1627337998949.ref@mail.yahoo.com> Message-ID: <1760081237.825858.1627337998949@mail.yahoo.com> I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong. ? ? ?thanks, glenn From pbryan at anode.ca Mon Jul 26 18:34:00 2021 From: pbryan at anode.ca (Paul Bryan) Date: Mon, 26 Jul 2021 15:34:00 -0700 Subject: a simple question In-Reply-To: <1760081237.825858.1627337998949@mail.yahoo.com> References: <1760081237.825858.1627337998949.ref@mail.yahoo.com> <1760081237.825858.1627337998949@mail.yahoo.com> Message-ID: It would help to know the error message you get every time. On Mon, 2021-07-26 at 22:19 +0000, Glenn Wilson via Python-list wrote: > I recently downloaded the latest version of python, 3.9.6. Everything > works except, the turtle module. I get an error message every time , > I use basic commands like forward, backward, right and left. My > syntax is correct: pat.forward(100) is an example. Can you tell me > what is wrong. > ? ? ?thanks, glenn From PythonList at DancesWithMice.info Mon Jul 26 21:47:17 2021 From: PythonList at DancesWithMice.info (dn) Date: Tue, 27 Jul 2021 13:47:17 +1200 Subject: a simple question In-Reply-To: <1760081237.825858.1627337998949@mail.yahoo.com> References: <1760081237.825858.1627337998949.ref@mail.yahoo.com> <1760081237.825858.1627337998949@mail.yahoo.com> Message-ID: On 27/07/2021 10.19, Glenn Wilson via Python-list wrote: > I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong. Python comes with "batteries included". However, if 'everything' was made immediately-available, each of your program[me]s would be very long. Accordingly, the 'batteries' are kept in what is called "The Python Standard Library". To use a library it must be import-ed into your code. Docs describing the library are available on-line, specifically the turtle module (and some examples of its use) can be found at: https://docs.python.org/3/library/turtle.html Have fun! -- Regards, =dn From avigross at verizon.net Mon Jul 26 22:29:36 2021 From: avigross at verizon.net (Avi Gross) Date: Mon, 26 Jul 2021 22:29:36 -0400 Subject: a simple question In-Reply-To: References: <1760081237.825858.1627337998949.ref@mail.yahoo.com> <1760081237.825858.1627337998949@mail.yahoo.com> Message-ID: <015401d7828f$3e6ca240$bb45e6c0$@verizon.net> In addition to the other requests for more info on a very ambiguous question, let me add one. Did the message suggest something worked on an earlier version and broke with a new version, or did they mean they just started USING the current version and hoped the version number was meaningful for the way they probably did not write proper code in the first place that loads the module(s) they need? -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Monday, July 26, 2021 9:46 PM To: python-list at python.org Subject: Re: a simple question On Mon, 26 Jul 2021 22:19:58 +0000 (UTC), Glenn Wilson via Python-list declaimed the following: >I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong. No we can't. Please provide a cut&paste (NOT a screen-grab image) of the error traceback, an indication of what OS/hardware you are running upon, etc. Maybe even which installer you downloaded (python.org, or some third-party repackager: ActiveState, Anaconda, M$ app store) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list From tjreedy at udel.edu Mon Jul 26 23:17:45 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 26 Jul 2021 23:17:45 -0400 Subject: a simple question In-Reply-To: <1760081237.825858.1627337998949@mail.yahoo.com> References: <1760081237.825858.1627337998949.ref@mail.yahoo.com> <1760081237.825858.1627337998949@mail.yahoo.com> Message-ID: On 7/26/2021 6:19 PM, Glenn Wilson via Python-list wrote: > I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong. On Windows, normal install, C:\Users\Terry>py -3.9 -m turtle C:\Users\Terry>py -3.9 -m turtledemo both work. -- Terry Jan Reedy From hongyi.zhao at gmail.com Tue Jul 27 04:55:33 2021 From: hongyi.zhao at gmail.com (hongy...@gmail.com) Date: Tue, 27 Jul 2021 01:55:33 -0700 (PDT) Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py Message-ID: <611ba3b7-4f01-4cd0-8d02-d81e1e3aa4b4n@googlegroups.com> I want to use [gtoken.py](https://github.com/ssut/py-googletrans/blob/master/googletrans/gtoken.py) through a socks5 proxy. Based on the comment [here](https://github.com/encode/httpx/issues/203#issuecomment-611914974) and the example usage in [gtoken.py](https://github.com/ssut/py-googletrans/blob/d15c94f176463b2ce6199a42a1c517690366977f/googletrans/gtoken.py#L29), I tried with the following method, but failed: ```python (datasci) werner at X10DAi:~$ ipython Python 3.9.1 (default, Feb 10 2021, 15:30:33) Type 'copyright', 'credits' or 'license' for more information IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help. In [1]: import socks In [2]: import socket In [3]: socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 18889) ...: socket.socket = socks.socksocket In [4]: from googletrans.gtoken import TokenAcquirer In [5]: acquirer=TokenAcquirer() In [6]: text = 'test' In [7]: tk= acquirer.do(text) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 tk= acquirer.do(text) ~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/googletrans/gtoken.py in do(self, text) 192 193 def do(self, text): --> 194 self._update() 195 tk = self.acquire(text) 196 return tk ~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/googletrans/gtoken.py in _update(self) 60 61 # this will be the same as python code after stripping out a reserved word 'var' ---> 62 code = self.RE_TKK.search(r.text).group(1).replace('var ', '') 63 # unescape special ascii characters such like a \x3d(=) 64 code = code.encode().decode('unicode-escape') AttributeError: 'NoneType' object has no attribute 'group' ``` Any hints for this problem will be highly appreciated. Regards, HY From skip.montanaro at gmail.com Tue Jul 27 11:03:33 2021 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 27 Jul 2021 10:03:33 -0500 Subject: Track 3.9 instead of 3.10? Message-ID: I have a development branch in my fork of python/cpython, the register2 branch of https://github.com/smontanaro/cpython. As I am dealing with virtual machine internals I've found the changes to the virtual machine between 3.9 and 3.10 too disruptive. I'd like to track 3.9 instead. How would I go about making the switch while minimizing the number of (inevitable) conflicts? I was thinking of diffing my current state against 3.10, then creating a new branch off 3.9 and applying the diff to that. That makes most of the effort outside of the view of git though, and won't necessarily minimize conflicts. Is there some way to do this totally within the git infrastructure? Thx, Skip From rosuav at gmail.com Tue Jul 27 11:30:40 2021 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 28 Jul 2021 01:30:40 +1000 Subject: Track 3.9 instead of 3.10? In-Reply-To: References: Message-ID: On Wed, Jul 28, 2021 at 1:05 AM Skip Montanaro wrote: > > I have a development branch in my fork of python/cpython, the > register2 branch of https://github.com/smontanaro/cpython. As I am > dealing with virtual machine internals I've found the changes to the > virtual machine between 3.9 and 3.10 too disruptive. I'd like to track > 3.9 instead. How would I go about making the switch while minimizing > the number of (inevitable) conflicts? I was thinking of diffing my > current state against 3.10, then creating a new branch off 3.9 and > applying the diff to that. That makes most of the effort outside of > the view of git though, and won't necessarily minimize conflicts. Is > there some way to do this totally within the git infrastructure? > If your changes (on top of 3.10) aren't too invasive, you could rebase those changes on top of 3.9, or cherry-pick them one by one. That would be a more granular way to "diff [your] current state against 3.10" (assuming you've been making those changes as individual commits). Check out the "rebase --onto" operation: https://git-scm.com/docs/git-rebase The first example of --onto (regarding master/next/topic branches) is what I think you're trying to do. ChrisA From info at wingware.com Tue Jul 27 15:15:00 2021 From: info at wingware.com (Wingware) Date: Tue, 27 Jul 2021 15:15:00 -0400 Subject: ANN: Wing Python IDE version 8 has been released Message-ID: <8f562d5d-c858-789d-004a-776a8a7f17d4@wingware.com> Wing 8 is a major new release that introduces support for development on Docker and LXC/LXD containers and Docker Compose clusters, a Python package management tool, improved project creation, improved static analysis and code warnings, support for Python 3.10, a native Apple Silicon (M1) build, a new Nord style theme, reduced application startup time, and much more. Details:? https://wingware.com/news/2021-07-26 Downloads:?? https://wingware.com/downloads == About Wing == Wing is a light-weight but full-featured Python IDE designed specifically for Python, with powerful editing, code inspection, testing, and debugging capabilities. Wing's deep code analysis provides auto-completion, auto-editing, and refactoring that speed up development. Its top notch debugger works with any Python code, locally or on a remote host, container, or cluster. Wing also supports test-driven development, version control, UI color and layout customization, and includes extensive documentation and support. Wing is available in three product levels:? Wing Pro is the full-featured Python IDE for professional developers, Wing Personal is a free Python IDE for students and hobbyists (omits some features), and Wing 101 is a very simplified free Python IDE for beginners (omits many features). Learn more at https://wingware.com/ From cs at cskk.id.au Tue Jul 27 19:07:58 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 28 Jul 2021 09:07:58 +1000 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: References: Message-ID: Just to follow on a bit to Dennis: C:\Users\Wulfraed\Documents\_Hg-Repositories\Python Progs>python googletrans_test.py Traceback (most recent call last): File "googletrans_test.py", line 4, in tk = acquirer.do(text) File "C:\Python38\lib\site-packages\googletrans\gtoken.py", line 194, in do self._update() File "C:\Python38\lib\site-packages\googletrans\gtoken.py", line 62, in _update code = self.RE_TKK.search(r.text).group(1).replace('var ', '') AttributeError: 'NoneType' object has no attribute 'group' The implication here is that: self.RE_TKK.search(r.text).group(1) generates the error because: self.RE_TKK.search(r.text) returned None instead of a regular expression match object. That means that "r.text" way not what was expected. Like Dennis, i note the remark "for internal use only", suggesting this was some internal Google code for doing something fiddly. It may not be the best thing for what you're trying to do. WRT to a socks proxy, Dennis showed that the issue occurs even without a proxy. I would advocate doing all your debugging without trying to use socks, then get to going through a socks proxy _after_ the main stuff is working. Cheers, Cameron Simpson From hongyi.zhao at gmail.com Tue Jul 27 22:24:35 2021 From: hongyi.zhao at gmail.com (hongy...@gmail.com) Date: Tue, 27 Jul 2021 19:24:35 -0700 (PDT) Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: References: Message-ID: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> On Wednesday, July 28, 2021 at 7:25:27 AM UTC+8, cameron... at gmail.com wrote: > Just to follow on a bit to Dennis: But I can't any reply from Dennis in this issue. > C:\Users\Wulfraed\Documents\_Hg-Repositories\Python Progs>python > googletrans_test.py > Traceback (most recent call last): > File "googletrans_test.py", line 4, in > tk = acquirer.do(text) > File "C:\Python38\lib\site-packages\googletrans\gtoken.py", line 194, in do > self._update() > File "C:\Python38\lib\site-packages\googletrans\gtoken.py", line 62, in _update > code = self.RE_TKK.search(r.text).group(1).replace('var ', '') > AttributeError: 'NoneType' object has no attribute 'group' > The implication here is that: > > self.RE_TKK.search(r.text).group(1) > > generates the error because: > > self.RE_TKK.search(r.text) > > returned None instead of a regular expression match object. That means > that "r.text" way not what was expected. > > Like Dennis, i note the remark "for internal use only", suggesting this > was some internal Google code for doing something fiddly. It may not be > the best thing for what you're trying to do. > > WRT to a socks proxy, Dennis showed that the issue occurs even without a > proxy. I would advocate doing all your debugging without trying to use > socks, then get to going through a socks proxy _after_ the main stuff is > working. > > Cheers, > Cameron Simpson From cs at cskk.id.au Wed Jul 28 01:32:27 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 28 Jul 2021 15:32:27 +1000 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> Message-ID: On 27Jul2021 19:24, Hongyi Zhao wrote: >On Wednesday, July 28, 2021 at 7:25:27 AM UTC+8, cameron... at gmail.com wrote: >> Just to follow on a bit to Dennis: > >But I can't any reply from Dennis in this issue. Odd, because I replied to his reply to you :-) If you're using a threaded view of the list, his reply should be right before mine. If you're not, it was about 6 hours before my reply. Cheers, Cameron Simpson From __peter__ at web.de Wed Jul 28 03:04:40 2021 From: __peter__ at web.de (Peter Otten) Date: Wed, 28 Jul 2021 09:04:40 +0200 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> Message-ID: On 28/07/2021 07:32, Cameron Simpson wrote: > On 27Jul2021 19:24, Hongyi Zhao wrote: >> On Wednesday, July 28, 2021 at 7:25:27 AM UTC+8, cameron... at gmail.com wrote: >>> Just to follow on a bit to Dennis: >> >> But I can't any reply from Dennis in this issue. > > Odd, because I replied to his reply to you :-) Perhaps it has something to do with the X-No-Archive flag set by Dennis? From Gronicus at SGA.Ninja Wed Jul 28 02:55:43 2021 From: Gronicus at SGA.Ninja (Steve) Date: Wed, 28 Jul 2021 02:55:43 -0400 Subject: Trying to read from a text file to generate a graph Message-ID: <014701d7837d$96643820$c32ca860$@SGA.Ninja> I am going though a struggle with this and just don't see where it fails. I am using the Dual Bar Graph.py program from https://matplotlib.org/stable/gallery/index.html website. The file from the web site works so that shows that all my installations are complete. My program, LibreGraphics 05.py program runs but the graph is all smutched up. I am pulling data from the EXCEL-FILE.txt into the program, selecting three values for each line and creating three variables formatted as is shown in the original demo file. When you run the program, choose 112 when prompted. You will see the values of the variables I want to pass to the graph section of the code. If the values are hardcoded, the graphs look good. When the variables generated by my section of the code, it does not. I am not sure what more to explain. Please help me.... Steve I am attaching a zip file. I hope it gets through. George Melly remarked to Mike Jagger on how lined his face was for one so young. Jagger replied ?They?re laughter lines George? to which Melly countered: ?Mick, nothing?s that f**king funny!?. From cs at cskk.id.au Wed Jul 28 04:25:18 2021 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 28 Jul 2021 18:25:18 +1000 Subject: Trying to read from a text file to generate a graph In-Reply-To: <014701d7837d$96643820$c32ca860$@SGA.Ninja> References: <014701d7837d$96643820$c32ca860$@SGA.Ninja> Message-ID: On 28Jul2021 02:55, Steve wrote: >I am going though a struggle with this and just don't see where it fails. >I am using the Dual Bar Graph.py program from https://matplotlib.org/stable/gallery/index.html website. >The file from the web site works so that shows that all my installations are complete. > >My program, LibreGraphics 05.py program runs but the graph is all smutched up. I am pulling data from the EXCEL-FILE.txt into the program, selecting three values for each line and creating three variables formatted as is shown in the original demo file. > >When you run the program, choose 112 when prompted. You will see the values of the variables I want to pass to the graph section of the code. If the values are hardcoded, the graphs look good. When the variables generated by my section of the code, it does not. > >I am not sure what more to explain. >Please help me.... >Steve > >I am attaching a zip file. I hope it gets through. Alas, the python-list is text only, and attachments are discarded. Is your programme small enough (one file, not insanely long) to just include inline in your next message? Have you printed the variables generated by your code? _Are_ they the same as the hardcoded values? You may want to graph different stuff, but start by trying to exactly reproduce the hardcoded value, but extracted from the file. Cheers, Cameron Simpson From hongyi.zhao at gmail.com Wed Jul 28 03:23:16 2021 From: hongyi.zhao at gmail.com (hongy...@gmail.com) Date: Wed, 28 Jul 2021 00:23:16 -0700 (PDT) Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> Message-ID: <23540568-4323-4bc5-9b7c-0731c217a973n@googlegroups.com> On Wednesday, July 28, 2021 at 3:05:11 PM UTC+8, Peter Otten wrote: > On 28/07/2021 07:32, Cameron Simpson wrote: > > On 27Jul2021 19:24, Hongyi Zhao wrote: > >> On Wednesday, July 28, 2021 at 7:25:27 AM UTC+8, cameron... at gmail.com wrote: > >>> Just to follow on a bit to Dennis: > >> > >> But I can't any reply from Dennis in this issue. > > > > Odd, because I replied to his reply to you :-) > Perhaps it has something to do with the X-No-Archive flag set by Dennis? I'm not sure. I use the Google Groups from Firefox for reading from/posting on this group. HY From Gronicus at SGA.Ninja Wed Jul 28 11:58:21 2021 From: Gronicus at SGA.Ninja (Steve) Date: Wed, 28 Jul 2021 11:58:21 -0400 Subject: Trying to read from a text file to generate a graph In-Reply-To: References: <014701d7837d$96643820$c32ca860$@SGA.Ninja> Message-ID: <018f01d783c9$648fa680$2daef380$@SGA.Ninja> I forgot about the no-file rule... On 28Jul2021 02:55, Steve wrote: >I am going though a struggle with this and just don't see where it fails. >I am using the Dual Bar Graph.py program from https://matplotlib.org/stable/gallery/index.html website. >The file from the web site works so that shows that all my installations are complete. > >My program, LibreGraphics 05.py program runs but the graph is all smutched up. I am pulling data from the EXCEL-FILE.txt into the program, selecting three values for each line and creating three variables formatted as is shown in the original demo file. > >When you run the program, choose 112 when prompted. You will see the values of the variables I want to pass to the graph section of the code. If the values are hardcoded, the graphs look good. When the variables generated by my section of the code, it does not. > >I am not sure what more to explain. >Please help me.... >Steve > >I am attaching a zip file. I hope it gets through. Alas, the python-list is text only, and attachments are discarded. Here is my code for the main program: ===================================================================== #https://matplotlib.org/stable/gallery/index.html import matplotlib.pyplot as plt import numpy as np ## In this first half of the program, I am reading lines of data from ## a file and reformatting them to create comms separated values into ## three variables. Sensors = "" TestStrips = "" SampleNumber = "" x = 1 SensorNumber = input("Enter senaor number: ") with open("_EXCEL-FILE.txt" , 'r') as infile: for lineEQN in infile: # loop to find each line in the file for that dose if (lineEQN[0:1]== "."): SN = lineEQN[44:48].strip() if (SensorNumber == SN): SN = x sn = "'" + str(SN) + "', " SampleNumber = SampleNumber + sn sv = lineEQN[25:29].strip() sv = sv + ", " Sensors = Sensors + sv tv = lineEQN[32:37].strip() tv = tv + ", " TestStrips = TestStrips + tv x += 1 SnLen = len(SampleNumber) -2 SampleNumber = SampleNumber[0:SnLen] labels = "[" + SampleNumber + "]" print("labels = " + labels) SenLen = len(Sensors) -2 Sensors = Sensors[0:SenLen] Sensors = "[" + Sensors + "]" print("Sensors = " + Sensors) TsLen = len(TestStrips) -2 TestStrips = TestStrips[0:TsLen] TestStrips = "[" + TestStrips + "]" print("TestStrips = " + TestStrips) labels = SampleNumber ## ============================================================= ## In this second half of the program, I want to use the three ## variables ## to populate a fraph. ## There are problems with this technique. ## ============================================================= ## With the following 6 lines of code commented-out, the graphing ## program uses the variables from the first half of the program ## and the graph fails ## ============================================================= ## Uncommented, the following works by overwriting the variables ## from the previous code and generates a proper graph. #label = ['1', '2', '3', '4', '5'] #Sensor = [150, 132, 182, 75, 117] #TestStrip = [211, 144, 219, 99, 142] #labels = label #Sensors = Sensor #TestStrips = TestStrip ## =========================================================== ## The follows is the original cose from the sample program ## with minor variable names and label changes. x = np.arange(len(labels)) # the label locations width = 0.35 # the width of the bars fig, ax = plt.subplots() rects1 = ax.bar(x - width/2, Sensors, width, label='Sensors') rects2 = ax.bar(x + width/2, TestStrips, width, label='TestStrips') # Add some text for labels, title and custom x-axis tick labels, etc. ax.set_ylabel('Glucose Readings') ax.set_title('Sensors VS Test Strip') ax.set_xticks(x) ax.set_xticklabels(labels) ax.legend() ax.bar_label(rects1, padding=3) ax.bar_label(rects2, padding=3) fig.tight_layout() plt.show() =========================================================== And here is a sample of the data file: .Thu Jul 22, 2021 20:47 250 277 27 111 2 .Fri Jul 23, 2021 00:05 188 194 6 111 3 .Fri Jul 23, 2021 09:08 142 166 24 111 3 .Fri Jul 23, 2021 12:58 138 165 27 111 3 .Fri Jul 23, 2021 22:32 356 391 35 111 3 .Sat Jul 24, 2021 09:44 150 211 61 112 4 .Sat Jul 24, 2021 13:24 132 144 12 112 4 .Sat Jul 24, 2021 16:40 182 213 31 112 4 .Sat Jul 24, 2021 19:52 75 99 24 112 4 .Sat Jul 24, 2021 23:19 117 142 25 112 4 From joepareti54 at gmail.com Wed Jul 28 12:09:15 2021 From: joepareti54 at gmail.com (joseph pareti) Date: Wed, 28 Jul 2021 18:09:15 +0200 Subject: [Errno 2] No such file or directory: Message-ID: The following code fails as shown in the title: *import subprocesscmd = 'ls -l /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 | awk "{print $9 }"'process = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr = process.communicate()print('stdout ',stdout)print('stderr ',stderr)* ---- Traceback (most recent call last): File "PreProcess_1a.py", line 3, in process = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ls -l /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 | awk "{print $9 -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From rosuav at gmail.com Wed Jul 28 12:15:43 2021 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Jul 2021 02:15:43 +1000 Subject: [Errno 2] No such file or directory: In-Reply-To: References: Message-ID: On Thu, Jul 29, 2021 at 2:10 AM joseph pareti wrote: > > The following code fails as shown in the title: > > > > > > > *import subprocesscmd = 'ls -l > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > | awk "{print $9 }"'process = subprocess.Popen([cmd], > stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr = > process.communicate()print('stdout ',stdout)print('stderr ',stderr)* > > ---- > > Traceback (most recent call last): > File "PreProcess_1a.py", line 3, in > process = subprocess.Popen([cmd], stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854, > in __init__ > self._execute_child(args, executable, preexec_fn, close_fds, > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line > 1702, in _execute_child > raise child_exception_type(errno_num, err_msg, err_filename) > FileNotFoundError: [Errno 2] No such file or directory: 'ls -l > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > | awk "{print $9 > First off, you'll want to post code in a way that keeps the formatting, otherwise it becomes very hard to read. But the immediate problem here is that Popen takes an array of command arguments, NOT a shell command line. You cannot invoke ls and pipe it into awk this way. Don't think like a shell script. Python has very good directory-listing functionality, and you will very very seldom need to shell out to pipelines. Figure out what you actually need to learn from the directory listing and get that information directly, rather than trying to use two external commands and text parsing. It's far FAR easier, cleaner, and safer that way. ChrisA From __peter__ at web.de Wed Jul 28 12:20:58 2021 From: __peter__ at web.de (Peter Otten) Date: Wed, 28 Jul 2021 18:20:58 +0200 Subject: [Errno 2] No such file or directory: In-Reply-To: References: Message-ID: On 28/07/2021 18:09, joseph pareti wrote: > The following code fails as shown in the title: > > > > > > > *import subprocesscmd = 'ls -l > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > | awk "{print $9 }"'process = subprocess.Popen([cmd], As a quick fix try process = subprocess.Popen( cmd # no list shell=True, ... # other args as above ) > stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr = > process.communicate()print('stdout ',stdout)print('stderr ',stderr)* > > ---- > > Traceback (most recent call last): > File "PreProcess_1a.py", line 3, in > process = subprocess.Popen([cmd], stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854, > in __init__ > self._execute_child(args, executable, preexec_fn, close_fds, > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line > 1702, in _execute_child > raise child_exception_type(errno_num, err_msg, err_filename) > FileNotFoundError: [Errno 2] No such file or directory: 'ls -l > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > | awk "{print $9 > From stephen.berman at gmx.net Wed Jul 28 17:36:24 2021 From: stephen.berman at gmx.net (Stephen Berman) Date: Wed, 28 Jul 2021 23:36:24 +0200 Subject: Trying to read from a text file to generate a graph In-Reply-To: <018f01d783c9$648fa680$2daef380$@SGA.Ninja> (Steve's message of "Wed, 28 Jul 2021 11:58:21 -0400") References: <014701d7837d$96643820$c32ca860$@SGA.Ninja> <018f01d783c9$648fa680$2daef380$@SGA.Ninja> Message-ID: <87k0larsqw.fsf@rub.de> [Resending to the list only, since I couldn't post it without subscribing.] On Wed, 28 Jul 2021 11:58:21 -0400 "Steve" wrote: > I forgot about the no-file rule... > >> On 28Jul2021 02:55, Steve wrote: >> I am going though a struggle with this and just don't see where it >> fails. I am using the Dual Bar Graph.py program from >> https://matplotlib.org/stable/gallery/index.html website. The file >> from the web site works so that shows that all my installations are >> complete. >> >> My program, LibreGraphics 05.py program runs but the graph is all >> smutched up. I am pulling data from the EXCEL-FILE.txt into the >> program, selecting three values for each line and creating three >> variables formatted as is shown in the original demo file. >> >> When you run the program, choose 112 when prompted. You will see the >> values of the variables I want to pass to the graph section of the >> code. If the values are hardcoded, the graphs look good. When the >> variables generated by my section of the code, it does not. The problem is due to the values of Sensors, TestStrips and SampleNumber being strings; what you want is for them to be lists, as in the assignments you commented out. And since the data from the file is read in as strings, you have to cast the elements of the Sensors and TestStrips lists to integers, since you want the numerical values. The following code does the job: Sensors = [] TestStrips = [] SampleNumber = [] x = 1 SensorNumber = input("Enter senaor number: ") with open("_EXCEL-FILE.txt", 'r') as infile: for lineEQN in infile: if (lineEQN[0:1]== "."): SN = lineEQN[44:48].strip() if (SensorNumber == SN): SN = x SampleNumber.append(SN) sv = lineEQN[25:29].strip() Sensors.append(int(sv)) tv = lineEQN[32:37].strip() TestStrips.append(int(tv)) x += 1 labels = SampleNumber Add the rest of your code from the second half to make the desired bar chart. Steve Berman From nospam at please.ty Wed Jul 28 18:07:24 2021 From: nospam at please.ty (jak) Date: Thu, 29 Jul 2021 00:07:24 +0200 Subject: a clean exit References: Message-ID: Il 23/07/2021 10:55, jak ha scritto: > Hello everybody, > I wrote a bot for telegram which consists of some processes of which the > main ones are: > - the main process: a list of callback functions > - a second process: managed with a message queue > - a third process: started by the library I use (python-telegram-bot) > which is used for the event/error log ('logging' module). > The problem is that sometimes I get an error from the library (python- > telegram-bot) via logging that my bot has no way of intercepting. The > error is "connection reset by pear" after which my program is no longer > called and I need to restart it. Typically this happens when Telegram > runs an update. > In any case I can know this error because, to write a log in a telegram > channel, I inherit the 'emit' function of the 'logging.Handler' class. > Hoping to have explained clearly enough the context in which the program > receives information about the error (we are inside a process not > launched directly from the main program), my question is: do you have > advice on how I can close my program in the way as clean as possible in > a easy way? > > Thanks in advance. Thanks to both of you for the replies. I know the rules you described to me for process synchronization but unfortunately, due to the structure of the library I am using, I cannot apply them. I can't even use try/except because the library, when the error occurs, displays it with the loggin libraries and no longer calls any of the callback functions my program is composed of. To understand when the error occurs, my only possibility is to intercept the logging, read the error string and, if it is not one of mine (mine all start with ":"), to close the program. Following some examples on the web I also configured a function to handle the error: ''' dispatcher.add_error_handler(callback=fallback_error, run_async=True) ''' but unfortunately after getting that error the library seems to hang and doesn't call my callback function. I was actually hoping to get some tricks to shut down all processes as a suggestion. Could I, for example, create a global list containing the ids of the processes I started and then kill each of them? Can it make sense? ty again From sean.dizazzo at gmail.com Wed Jul 28 22:08:24 2021 From: sean.dizazzo at gmail.com (Sean DiZazzo) Date: Wed, 28 Jul 2021 19:08:24 -0700 (PDT) Subject: a simple question In-Reply-To: References: <1760081237.825858.1627337998949.ref@mail.yahoo.com> <1760081237.825858.1627337998949@mail.yahoo.com> Message-ID: On Tuesday, July 27, 2021 at 5:05:27 AM UTC-7, Terry Reedy wrote: > On 7/26/2021 6:19 PM, Glenn Wilson via Python-list wrote: > > I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong. > On Windows, normal install, > C:\Users\Terry>py -3.9 -m turtle > C:\Users\Terry>py -3.9 -m turtledemo > both work. > > > -- > Terry Jan Reedy Welcome to programming!! Ain't it fun?! From Gronicus at SGA.Ninja Thu Jul 29 04:11:06 2021 From: Gronicus at SGA.Ninja (Steve) Date: Thu, 29 Jul 2021 04:11:06 -0400 Subject: Trying to read from a text file to generate a graph In-Reply-To: <87k0larsqw.fsf@rub.de> References: <014701d7837d$96643820$c32ca860$@SGA.Ninja> <018f01d783c9$648fa680$2daef380$@SGA.Ninja> <87k0larsqw.fsf@rub.de> Message-ID: <021d01d78451$48bcf740$da36e5c0$@SGA.Ninja> Thank you, the responses here have been extremely helpful. Steve ---------------------------------------------------------------------------- ---------------- Footnote: There's 99 bugs in the code, in the code. 99 bugs in the code. Take one down and patch it all around. Now there's 117 bugs in the code. -----Original Message----- From: Python-list On Behalf Of Stephen Berman Sent: Wednesday, July 28, 2021 5:36 PM To: python-list at python.org Subject: Re: Trying to read from a text file to generate a graph [Resending to the list only, since I couldn't post it without subscribing.] On Wed, 28 Jul 2021 11:58:21 -0400 "Steve" wrote: > I forgot about the no-file rule... > >> On 28Jul2021 02:55, Steve wrote: >> I am going though a struggle with this and just don't see where it >> fails. I am using the Dual Bar Graph.py program from >> https://matplotlib.org/stable/gallery/index.html website. The file >> from the web site works so that shows that all my installations are >> complete. >> >> My program, LibreGraphics 05.py program runs but the graph is all >> smutched up. I am pulling data from the EXCEL-FILE.txt into the >> program, selecting three values for each line and creating three >> variables formatted as is shown in the original demo file. >> >> When you run the program, choose 112 when prompted. You will see the >> values of the variables I want to pass to the graph section of the >> code. If the values are hardcoded, the graphs look good. When the >> variables generated by my section of the code, it does not. The problem is due to the values of Sensors, TestStrips and SampleNumber being strings; what you want is for them to be lists, as in the assignments you commented out. And since the data from the file is read in as strings, you have to cast the elements of the Sensors and TestStrips lists to integers, since you want the numerical values. The following code does the job: Sensors = [] TestStrips = [] SampleNumber = [] x = 1 SensorNumber = input("Enter senaor number: ") with open("_EXCEL-FILE.txt", 'r') as infile: for lineEQN in infile: if (lineEQN[0:1]== "."): SN = lineEQN[44:48].strip() if (SensorNumber == SN): SN = x SampleNumber.append(SN) sv = lineEQN[25:29].strip() Sensors.append(int(sv)) tv = lineEQN[32:37].strip() TestStrips.append(int(tv)) x += 1 labels = SampleNumber Add the rest of your code from the second half to make the desired bar chart. Steve Berman -- https://mail.python.org/mailman/listinfo/python-list From as at sci.fi Thu Jul 29 03:29:46 2021 From: as at sci.fi (Anssi Saari) Date: Thu, 29 Jul 2021 10:29:46 +0300 Subject: Trying to read from a text file to generate a graph References: <014701d7837d$96643820$c32ca860$@SGA.Ninja> Message-ID: "Steve" writes: > I am going though a struggle with this and just don't see where it fails. It seems to me you're putting your data into strings when you need to put it into lists. And no, adding brackets and commas to your strings so that printing out the strings makes them look like lists doesn't make them into lists. There's python tutorial at https://docs.python.org/3/tutorial/index.html which may help with the basics. From ast at invalid Thu Jul 29 05:39:30 2021 From: ast at invalid (ast) Date: Thu, 29 Jul 2021 11:39:30 +0200 Subject: Subtle difference between any(a list) and any(a generator) with Python 3.9 Message-ID: <61027753$0$3715$426a74cc@news.free.fr> Hello Reading PEP572 about Python 3.9 assignment expressions, I discovered a subtle difference between any(a list) and any(a generator) see: >>> lines = ["azerty", "#qsdfgh", "wxcvbn"] >>> any((comment := line).startswith('#') for line in lines) True >>> comment "#qsdfgh" >>> any([(comment := line).startswith('#') for line in lines]) True >>> comment 'wxcvbn' The two code snippets which seems very similar provide a different value for "comment". When "any" deals with a generator, it stops as soon it finds a True value and returns True. When "any" deals with a list, the whole list is calculated first, and then "any" looks for a True. Before 3.9 and the walrus operator, the two ways always provide the same result, in a faster way with a generator. With 3.9 and the walrus operator, result can be different From rosuav at gmail.com Thu Jul 29 05:59:30 2021 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Jul 2021 19:59:30 +1000 Subject: Subtle difference between any(a list) and any(a generator) with Python 3.9 In-Reply-To: <61027753$0$3715$426a74cc@news.free.fr> References: <61027753$0$3715$426a74cc@news.free.fr> Message-ID: On Thu, Jul 29, 2021 at 7:49 PM ast wrote: > > Hello > > Reading PEP572 about Python 3.9 assignment expressions, > I discovered a subtle difference between any(a list) > and any(a generator) > > see: > > >>> lines = ["azerty", "#qsdfgh", "wxcvbn"] > >>> any((comment := line).startswith('#') for line in lines) > True > >>> comment > "#qsdfgh" > > >>> any([(comment := line).startswith('#') for line in lines]) > True > >>> comment > 'wxcvbn' "any" is irrelevant here. What you're seeing is that a list comprehension is evaluated fully, and a generator expression isn't. That's exactly what they're meant to do :) ChrisA From arakelthedragon at gmail.com Thu Jul 29 06:10:50 2021 From: arakelthedragon at gmail.com (Arak Rachael) Date: Thu, 29 Jul 2021 03:10:50 -0700 (PDT) Subject: Fast help with Python program Message-ID: <50370ea0-461a-4ee7-b3a7-35e9fa3cf11cn@googlegroups.com> Hi guys, I need fast help with this, can you please look at it? I don't get how to visualize on the 3 axis in the for cycle with the list of colors and count of colors that I get from my array. And I also don't get how to cluster the colors based on how many colors there are in the second array from get_unique_colors(img). https://www.dropbox.com/s/ifvecwb5c0iy2pa/test_scripts.py?dl=0 From __peter__ at web.de Thu Jul 29 09:45:26 2021 From: __peter__ at web.de (Peter Otten) Date: Thu, 29 Jul 2021 15:45:26 +0200 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: <0o13ggttqm8p4l2iusjafjp88jmti151ap@4ax.com> References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> <0o13ggttqm8p4l2iusjafjp88jmti151ap@4ax.com> Message-ID: On 28/07/2021 18:40, Dennis Lee Bieber wrote: > On Wed, 28 Jul 2021 09:04:40 +0200, Peter Otten <__peter__ at web.de> > declaimed the following: > >> >> Perhaps it has something to do with the X-No-Archive flag set by Dennis? > > According to my properties page in Agent, I've turned that off except > if the message I'm replying to has it set. I'm yet to see an archived post by you -- maybe that setting is overridden somewhere. From joepareti54 at gmail.com Thu Jul 29 10:42:27 2021 From: joepareti54 at gmail.com (joseph pareti) Date: Thu, 29 Jul 2021 16:42:27 +0200 Subject: [Errno 2] No such file or directory: In-Reply-To: References: Message-ID: indeed. There are better options than the one I attempted. Thanks for the advice Am Mi., 28. Juli 2021 um 18:19 Uhr schrieb Chris Angelico : > On Thu, Jul 29, 2021 at 2:10 AM joseph pareti > wrote: > > > > The following code fails as shown in the title: > > > > > > > > > > > > > > *import subprocesscmd = 'ls -l > > > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > > | awk "{print $9 }"'process = subprocess.Popen([cmd], > > stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr = > > process.communicate()print('stdout ',stdout)print('stderr ',stderr)* > > > > ---- > > > > Traceback (most recent call last): > > File "PreProcess_1a.py", line 3, in > > process = subprocess.Popen([cmd], stdout=subprocess.PIPE, > > stderr=subprocess.PIPE) > > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line > 854, > > in __init__ > > self._execute_child(args, executable, preexec_fn, close_fds, > > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line > > 1702, in _execute_child > > raise child_exception_type(errno_num, err_msg, err_filename) > > FileNotFoundError: [Errno 2] No such file or directory: 'ls -l > > > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > > | awk "{print $9 > > > > First off, you'll want to post code in a way that keeps the > formatting, otherwise it becomes very hard to read. > > But the immediate problem here is that Popen takes an array of command > arguments, NOT a shell command line. You cannot invoke ls and pipe it > into awk this way. > > Don't think like a shell script. Python has very good > directory-listing functionality, and you will very very seldom need to > shell out to pipelines. Figure out what you actually need to learn > from the directory listing and get that information directly, rather > than trying to use two external commands and text parsing. It's far > FAR easier, cleaner, and safer that way. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From dieter at handshake.de Thu Jul 29 12:11:44 2021 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 29 Jul 2021 18:11:44 +0200 Subject: a clean exit In-Reply-To: References: Message-ID: <24834.54080.803610.549063@ixdm.fritz.box> jak wrote at 2021-7-29 00:07 +0200: > ... >Thanks to both of you for the replies. I know the rules you described to >me for process synchronization but unfortunately, due to the structure >of the library I am using, I cannot apply them. I can't even use >try/except because the library, when the error occurs, displays it with >the loggin libraries and no longer calls any of the callback functions >my program is composed of. I assume that you are using a class deriving from a library class where your application is defined by methods on this class. Look at the library class's code. Almost surely, the error in handled by one of its methods. Override this method in your class as necessary. -- Dieter From wlfraed at ix.netcom.com Thu Jul 29 11:43:16 2021 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 29 Jul 2021 11:43:16 -0400 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> <0o13ggttqm8p4l2iusjafjp88jmti151ap@4ax.com> Message-ID: On Thu, 29 Jul 2021 15:45:26 +0200, Peter Otten <__peter__ at web.de> declaimed the following: >On 28/07/2021 18:40, Dennis Lee Bieber wrote: >> On Wed, 28 Jul 2021 09:04:40 +0200, Peter Otten <__peter__ at web.de> >> declaimed the following: >> >>> >>> Perhaps it has something to do with the X-No-Archive flag set by Dennis? >> >> According to my properties page in Agent, I've turned that off except >> if the message I'm replying to has it set. > >I'm yet to see an archived post by you -- maybe that setting is >overridden somewhere. And naturally, once I found the legacy (per persona) custom setting, I failed to edit the main persona. Hopefully this time it's set... Appears Agent added the per "folder" and "default' [x] X-no-Archive flags in some later release, and those are what I've been tweaking... But looking at the INI file, I found there were persona specific custom settings for "additional header fields", Which I likely set up back in the days of Agent 5 or so, currently on Agent 8 -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From michael.stemper at gmail.com Thu Jul 29 13:57:02 2021 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Thu, 29 Jul 2021 12:57:02 -0500 Subject: Rotation of a cube Message-ID: I would like to animate the rotation of a 3-cube. I know how to do animation with pygame. My first thought was to set up a cube as a list of coordinates, and then project those coordinates onto a plane by ray-tracing from a viewpoint. I could then incrementally rotate it using the rotation matrix[1], briefly showing each step. However, it seems to me that this is a solved problem, so there is probably a module that will do most of the scutwork for me. Any suggestions on where to find such a module? Thanks. [1] -- Michael F. Stemper This sentence no verb. From tjreedy at udel.edu Thu Jul 29 14:14:11 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 29 Jul 2021 14:14:11 -0400 Subject: Subtle difference between any(a list) and any(a generator) with Python 3.9 In-Reply-To: <61027753$0$3715$426a74cc@news.free.fr> References: <61027753$0$3715$426a74cc@news.free.fr> Message-ID: On 7/29/2021 5:39 AM, Unknown wrote: > Hello > > Reading PEP572 about Python 3.9 assignment expressions, > I discovered a subtle difference between any(a list) > and any(a generator) > > see: > > >>> lines = ["azerty", "#qsdfgh", "wxcvbn"] > >>> any((comment := line).startswith('#') for line in lines) > True > >>> comment > "#qsdfgh" > > >>> any([(comment := line).startswith('#') for line in lines]) Same as >>> booleans = [(comment := line).startswith('#') for line in lines] >>> # comment == last item. >>> any(booleans) # Iteration though booleans stops at 1st True. > True >>> comment > 'wxcvbn' > > The two code snippets which seems very similar provide a > different value for "comment". > > When "any" deals with a generator, it stops as soon it finds > a True value and returns True. > > When "any" deals with a list, the whole list is calculated > first, and then "any" looks for a True. > > Before 3.9 and the walrus operator, the two ways always provide > the same result, in a faster way with a generator. Since the 'two ways' involve the new :=, I have no idea what 'two ways' and 'same result' you mean before :=. > With 3.9 and the walrus operator, result can be different -- Terry Jan Reedy From rosuav at gmail.com Thu Jul 29 15:59:00 2021 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 30 Jul 2021 05:59:00 +1000 Subject: Subtle difference between any(a list) and any(a generator) with Python 3.9 In-Reply-To: References: <61027753$0$3715$426a74cc@news.free.fr> Message-ID: On Fri, Jul 30, 2021 at 5:40 AM Terry Reedy wrote: > Since the 'two ways' involve the new :=, I have no idea what 'two ways' > and 'same result' you mean before :=. > I'm not sure, but I think that a lot of people read patch notes as if they say "this is how everyone needs to do things now", and then blame or credit the newest features with everything that happens. Personally, I'd search for the comments like this: for line in lines: if line.startswith("#"): ... # whatever you do if there is one break else: ... # whatever you do if there isn't one But if you have to do it with a one-liner, much cleaner to use next on your filter: comment = next((l for l in lines if l.startswith("#")). None) Neither of these depends on :=. I don't know what "two ways" there are, but capturing the first element that matches a filter is a pretty normal thing to do. ChrisA From Gronicus at SGA.Ninja Thu Jul 29 17:24:14 2021 From: Gronicus at SGA.Ninja (Steve) Date: Thu, 29 Jul 2021 17:24:14 -0400 Subject: How do I modify a bar graph? Message-ID: <028201d784c0$1524cec0$3f6e6c40$@SGA.Ninja> The following code is from the site: https://matplotlib.org/stable/gallery/index.html bar graph. Sometimes I want to project a graph that contains almost 100 elements. The program shows everything crammed into a default size graph. Can I modify the size of the graph and make it longer? Also, the numbers in the graph are horizontal, can I make them vertical? 100 Vs 1 0 0 ? ========================================================= Import matplotlib.pyplot as plt import numpy as np labels = ['G1', 'G2', 'G3', 'G4', 'G5'] men_means = [20, 34, 30, 35, 27] women_means = [25, 32, 34, 20, 25] x = np.arange(len(labels)) # the label locations width = 0.35 # the width of the bars fig, ax = plt.subplots() rects1 = ax.bar(x - width/2, men_means, width, label='Men') rects2 = ax.bar(x + width/2, women_means, width, label='Women') # Add some text for labels, title and custom x-axis tick labels, etc. ax.set_ylabel('Scores') ax.set_title('Scores by group and gender') ax.set_xticks(x) ax.set_xticklabels(labels) ax.legend() ax.bar_label(rects1, padding=3) ax.bar_label(rects2, padding=3) fig.tight_layout() plt.show() ======================================== Steve From greg.ewing at canterbury.ac.nz Thu Jul 29 18:22:43 2021 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 30 Jul 2021 10:22:43 +1200 Subject: Rotation of a cube In-Reply-To: References: Message-ID: On 30/07/21 5:57 am, Michael F. Stemper wrote: > I would like to animate the rotation of a 3-cube.ng each step. > > However, it seems to me that this is a solved problem, so there is > probably a module that will do most of the scutwork for me. You might find something useful here: https://medium.com/quick-code/3d-graphics-using-the-python-standard-library-99914447760c -- Greg From __peter__ at web.de Fri Jul 30 07:17:50 2021 From: __peter__ at web.de (Peter Otten) Date: Fri, 30 Jul 2021 13:17:50 +0200 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py In-Reply-To: References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> <0o13ggttqm8p4l2iusjafjp88jmti151ap@4ax.com> Message-ID: On 29/07/2021 17:43, Dennis Lee Bieber wrote: > On Thu, 29 Jul 2021 15:45:26 +0200, Peter Otten <__peter__ at web.de> > declaimed the following: > >> On 28/07/2021 18:40, Dennis Lee Bieber wrote: >>> On Wed, 28 Jul 2021 09:04:40 +0200, Peter Otten <__peter__ at web.de> >>> declaimed the following: >>> >>>> >>>> Perhaps it has something to do with the X-No-Archive flag set by Dennis? >>> >>> According to my properties page in Agent, I've turned that off except >>> if the message I'm replying to has it set. >> >> I'm yet to see an archived post by you -- maybe that setting is >> overridden somewhere. > > And naturally, once I found the legacy (per persona) custom setting, I > failed to edit the main persona. Hopefully this time it's set... https://mail.python.org/pipermail/python-list/2021-July/902975.html You are now officially archived ;) From storchaka at gmail.com Fri Jul 30 04:21:35 2021 From: storchaka at gmail.com (Serhiy Storchaka) Date: Fri, 30 Jul 2021 11:21:35 +0300 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: 23.07.21 11:20, Bartosz Golaszewski ????: > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. I think that it would be much easier to define it in Python, and then either import a Python module in your C code, or exec a Python code as a string. From Joseph.Schachner at Teledyne.com Fri Jul 30 13:33:36 2021 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Fri, 30 Jul 2021 17:33:36 +0000 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: Instead of struggling to define an enum in C that can be read in Python - I'm assuming you can pass strings back and forth - why not just print whatever you need to give to Python into a string (or maybe 2 strings) and send it to Python as string? Python is a dynamic language, it can quickly build an enum type from one string and instantiate enums of that type from the other string. In short, if you have problems creating an enum in C and passing it to Python, give the problems to Python! Let it create the enum. --- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data -----Original Message----- From: Serhiy Storchaka Sent: Friday, July 30, 2021 4:22 AM To: python-list at python.org Subject: Re: Defining a Python enum in a C extension - am I doing this right? 23.07.21 11:20, Bartosz Golaszewski ????: > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. I think that it would be much easier to define it in Python, and then either import a Python module in your C code, or exec a Python code as a string. From wlfraed at ix.netcom.com Fri Jul 30 10:25:04 2021 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 30 Jul 2021 10:25:04 -0400 Subject: Generate a Google Translate API token through the Socks5 proxy using gtoken.py References: <4496f421-65dc-4b61-b4cd-9a8780ac5c15n@googlegroups.com> <0o13ggttqm8p4l2iusjafjp88jmti151ap@4ax.com> Message-ID: On Fri, 30 Jul 2021 13:17:50 +0200, Peter Otten <__peter__ at web.de> declaimed the following: > >https://mail.python.org/pipermail/python-list/2021-July/902975.html > >You are now officially archived ;) Pity the choice was the boolean "X-No-Archive"... Consensus implementation of an "X-Expire-After: " would have been friendlier (Google Groups USED to expire X-No-Archive posts after a week, instead of the current practice of: post says no-archive, delete immediately). -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From charles at sollum.tech Fri Jul 30 12:55:05 2021 From: charles at sollum.tech (Charles Smith) Date: Fri, 30 Jul 2021 09:55:05 -0700 (PDT) Subject: Importing modules with arguments Message-ID: <32df0b54-2e76-4c7e-b6cb-23bfd0abf333n@googlegroups.com> I have found myself wanting to import module and provide arguments to them. There's two main reason I could think of for this. First is to prevent a circular import, though most of circular imports can be prevented by changing the design. The second reason is to invert dependencies between two modules. It occurred to me when using libraries like FastAPI or Flask that it would be nicer to use and leaner if instead of: 1. Import FastAPI Router or FastAPI object directly 2. Create a Router 3. Use the route decorators We could simply import a module with importlib and provide the router itself. You can then keep all the FastAPI related code inside its module and only have clean list of endpoints. Now this is actually doable right now, here's the snippet: https://gist.github.com/BinarSkugga/c281cbbe36e7f11bc0fd143ea1bb4dd4 Disclaimer: I have no idea what are the implication of this but I'd like to have it as a feature instead of this hack. From rosuav at gmail.com Fri Jul 30 14:05:24 2021 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Jul 2021 04:05:24 +1000 Subject: Importing modules with arguments In-Reply-To: <32df0b54-2e76-4c7e-b6cb-23bfd0abf333n@googlegroups.com> References: <32df0b54-2e76-4c7e-b6cb-23bfd0abf333n@googlegroups.com> Message-ID: On Sat, Jul 31, 2021 at 3:48 AM Charles Smith wrote: > > I have found myself wanting to import module and provide arguments to them. There's two main reason I could think of for this. First is to prevent a circular import, though most of circular imports can be prevented by changing the design. The second reason is to invert dependencies between two modules. It occurred to me when using libraries like FastAPI or Flask that it would be nicer to use and leaner if instead of: > 1. Import FastAPI Router or FastAPI object directly > 2. Create a Router > 3. Use the route decorators > > We could simply import a module with importlib and provide the router itself. You can then keep all the FastAPI related code inside its module and only have clean list of endpoints. Now this is actually doable right now, here's the snippet: https://gist.github.com/BinarSkugga/c281cbbe36e7f11bc0fd143ea1bb4dd4 > > Disclaimer: I have no idea what are the implication of this but I'd like to have it as a feature instead of this hack. > One problem here is that imports are cached. If module #1 says "import flask", Python runs the module and gives back the result; if module #2 subsequently says "import flask", Python returns the exact same module from the cache. That won't work well with parameterization. I would recommend either: 1) Import a class from the module, then instantiate; or 2) Import the module, then make a change to its globals. The first one allows different modules to have different parameters; the second would have different parameters overwrite each other. (And it would be very clear that it's going to do so.) The idiom "from flask import Flask; flask = Flask()" is a bit clunky, but it's probably the best you have for adding parameters. (In this specific case, "app = Flask()", which is more common, but same difference.) I can't really imagine shortening it very much; a syntax like "import flask()" would be confusing, and every other syntax I can think of will be only marginally better than the standard idiom. There is one important situation where you can't just import the whole module and then do stuff, and that's choosing to import *less* than the full module. For that use-case, it kinda has to be a package, but then you should be able to do something like: package/__init__.py # all the basic stuff in this file package/expensive1.py package/expensive2.py package/expensive3.py # different parts package/all.py from . import expensive1, expensive2, expensive3 Then you can say something like: import package.expensive2 and it'll only get some part of the package. It's a bit unideal in that the namespace has to reflect this, but with careful use of __getattr__, you could conceal those details (at the cost of even more complexity). On the upside, though, the parameterization doesn't have to break anything - if module 1 imports one part of the package, and module 2 imports another part, both parts will coexist nicely. ChrisA From charles at sollum.tech Fri Jul 30 14:54:27 2021 From: charles at sollum.tech (Charles Smith) Date: Fri, 30 Jul 2021 11:54:27 -0700 (PDT) Subject: Importing modules with arguments In-Reply-To: References: <32df0b54-2e76-4c7e-b6cb-23bfd0abf333n@googlegroups.com> Message-ID: <6e08b664-f55a-490a-9625-1b7825f24396n@googlegroups.com> First off, thanks for the answer. I don't see the cached module as a problem here. If you provide arguments to a module, the goal is "most likely" to alter/parameterize the behavior of the first import. Now, I agree that behavior becomes unpredictable because passing different parameters on subsequent imports won't change the behavior of the imported module . One thing that could be done is to memoize those imports based on the parameters (this is a huge change to how imports works so its a bit yikes). Another solution would be to simply not cache parameterized imports. You sacrifice performance for added flexibility which I think is fair. I do however agree about partial imports. It would be rather complex to properly pass the context but its certainly doable. From rosuav at gmail.com Fri Jul 30 15:25:16 2021 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Jul 2021 05:25:16 +1000 Subject: Importing modules with arguments In-Reply-To: <6e08b664-f55a-490a-9625-1b7825f24396n@googlegroups.com> References: <32df0b54-2e76-4c7e-b6cb-23bfd0abf333n@googlegroups.com> <6e08b664-f55a-490a-9625-1b7825f24396n@googlegroups.com> Message-ID: On Sat, Jul 31, 2021 at 5:11 AM Charles Smith wrote: > > First off, thanks for the answer. I don't see the cached module as a problem here. If you provide arguments to a module, the goal is "most likely" to alter/parameterize the behavior of the first import. Now, I agree that behavior becomes unpredictable because passing different parameters on subsequent imports won't change the behavior of the imported module . > The trouble is that if any other module has already imported the one you're trying to parameterize, then your code won't know that the parameters haven't been applied. It's action at a distance. > One thing that could be done is to memoize those imports based on the parameters (this is a huge change to how imports works so its a bit yikes). That's functionally equivalent to importing a class and then instantiating, but with an automated cache. Could be interesting, but belongs inside the module, not as a language mechanic, IMO. > Another solution would be to simply not cache parameterized imports. You sacrifice performance for added flexibility which I think is fair. And that's functionally equivalent to importing a class and then instantiating, *without* the automated cache. :) > I do however agree about partial imports. It would be rather complex to properly pass the context but its certainly doable. > Yeah. So here's a possibility. Craft a module-level __getattr__ function that does the caching behaviour you want. Then you can "from modulename import Thing", where the precise name you want is the selection of parameter. The __getattr__ function can also set it as an intrinsic attribute (thus offering high performance caching - it'll bypass __getattr_ the second time). Other than that, though, there's not really a lot of parameterization that would make sense as part of the import (if you need to say something like "import random; random.seed(12345)", that's not really going to fit into the import statement). ChrisA From sean.dizazzo at gmail.com Fri Jul 30 19:45:24 2021 From: sean.dizazzo at gmail.com (Sean DiZazzo) Date: Fri, 30 Jul 2021 16:45:24 -0700 (PDT) Subject: [Errno 2] No such file or directory: In-Reply-To: References: Message-ID: <8251d3c3-b081-4d13-9aff-a97ede03f926n@googlegroups.com> On Thursday, July 29, 2021 at 7:42:58 AM UTC-7, joseph pareti wrote: > indeed. There are better options than the one I attempted. Thanks for the > advice > > Am Mi., 28. Juli 2021 um 18:19 Uhr schrieb Chris Angelico >: > > On Thu, Jul 29, 2021 at 2:10 AM joseph pareti > > wrote: > > > > > > The following code fails as shown in the title: > > > > > > > > > > > > > > > > > > > > > *import subprocesscmd = 'ls -l > > > > > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > > > | awk "{print $9 }"'process = subprocess.Popen([cmd], > > > stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr = > > > process.communicate()print('stdout ',stdout)print('stderr ',stderr)* > > > > > > ---- > > > > > > Traceback (most recent call last): > > > File "PreProcess_1a.py", line 3, in > > > process = subprocess.Popen([cmd], stdout=subprocess.PIPE, > > > stderr=subprocess.PIPE) > > > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line > > 854, > > > in __init__ > > > self._execute_child(args, executable, preexec_fn, close_fds, > > > File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line > > > 1702, in _execute_child > > > raise child_exception_type(errno_num, err_msg, err_filename) > > > FileNotFoundError: [Errno 2] No such file or directory: 'ls -l > > > > > /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48 > > > | awk "{print $9 > > > > > > > First off, you'll want to post code in a way that keeps the > > formatting, otherwise it becomes very hard to read. > > > > But the immediate problem here is that Popen takes an array of command > > arguments, NOT a shell command line. You cannot invoke ls and pipe it > > into awk this way. > > > > Don't think like a shell script. Python has very good > > directory-listing functionality, and you will very very seldom need to > > shell out to pipelines. Figure out what you actually need to learn > > from the directory listing and get that information directly, rather > > than trying to use two external commands and text parsing. It's far > > FAR easier, cleaner, and safer that way. > > > > ChrisA > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > -- > Regards, > Joseph Pareti - Artificial Intelligence consultant > Joseph Pareti's AI Consulting Services > https://www.joepareti54-ai.com/ > cell +49 1520 1600 209 > cell +39 339 797 0644 I prefer LOLCODE for these kinds of tasks. HAI 1.2 I HAS A VAR ITZ MAH_DIRECTORY GIMMEH MAH_DIRECTORY CAN HAS STDIO? BOTH SAEM MAH_DIRECTORY AN "/media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48", O RLY? YA RLY, VISIBLE "FILEZ GO HERE!" NO WAI, VISIBLE "WTF IZ THAT?" OIC KTHXBYE From brgl at bgdev.pl Sat Jul 31 09:01:13 2021 From: brgl at bgdev.pl (Bartosz Golaszewski) Date: Sat, 31 Jul 2021 15:01:13 +0200 Subject: Defining a Python enum in a C extension - am I doing this right? In-Reply-To: References: Message-ID: On Fri, Jul 30, 2021 at 2:41 PM Serhiy Storchaka wrote: > > 23.07.21 11:20, Bartosz Golaszewski ????: > > I'm working on a Python C extension and I would like to expose a > > custom enum (as in: a class inheriting from enum.Enum) that would be > > entirely defined in C. > > I think that it would be much easier to define it in Python, and then > either import a Python module in your C code, or exec a Python code as a > string. > You mean: evaluate a string like this: ''' import enum class FooBar(enum.Enum): FOO = 1 BAR = 2 BAZ = 3 ''' And then pull in the FooBar type from the resulting dictionary into my C code? Sounds good actually. I think I'll be able to add the FooBar type to another type's tp_dict too - because some enums I want to create will be nested in other classes. Bart From veerchakraborty612 at gmail.com Sat Jul 31 04:37:05 2021 From: veerchakraborty612 at gmail.com (37_VA_VEER CHAKRABORTY) Date: Sat, 31 Jul 2021 14:07:05 +0530 Subject: 'Pygame Module' not working Message-ID: Hi, I am a beginner in Python and I have started with the 'Pygame' module. I was making a 'Flappy Bird' game with the module with the help of Youtube videos. I was able to create a blank window. I had downloaded the game assets in my computer in a folder called 'Python' and in a subfolder called 'assets'. I tried to upload the Flappy Bird picture and other sprites with the code - pygame.image.load('assets/Flappy Bird.png') However, when I ran the script it was showing an error message - File not found Please advise me on how to upload the sprites and where I was going wrong. Thank You, Regards From meirbusinessac at gmail.com Sat Jul 31 14:00:05 2021 From: meirbusinessac at gmail.com (Meir Davidov) Date: Sat, 31 Jul 2021 11:00:05 -0700 (PDT) Subject: Scraping Shopify Stores - With Python [example included inside] Message-ID: <00055252-168e-4797-9b69-1ae64242bd02n@googlegroups.com> There is a chrome extension that shows live sales of websites that are built on the shopify ip. For example, in the image below, there is a pretty popular store- gymshark, which is built on shopify.. and every minute they get a sale it shows here on the extension: http://i.prntscr.com/K2lb1yS-QyqB1oYmHqV4yQ.png Any of you know how to get this information? Probably anytime that there is a sale the customer is redirected to a thank you page, and every time it happens it might ping a sale notification here but how can we extract that information From michael.stemper at gmail.com Sat Jul 31 15:48:37 2021 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Sat, 31 Jul 2021 14:48:37 -0500 Subject: 'Pygame Module' not working In-Reply-To: References: Message-ID: On 31/07/2021 03.37, 37_VA_VEER CHAKRABORTY wrote: > Hi, > I am a beginner in Python and I have started with the 'Pygame' module. I > was making a 'Flappy Bird' game with the module with the help of Youtube > videos. I was able to create a blank window. I had downloaded the game > assets in my computer in a folder called 'Python' and in a subfolder called > 'assets'. I tried to upload the Flappy Bird picture and other sprites with > the code - > pygame.image.load('assets/Flappy Bird.png') > However, when I ran the script it was showing an error message - File not > found Are you running your program in the parent directory of "assets"? What happens when you go into the python interpreter (REPL) and import pygame followed by executing that function? -- Michael F. Stemper Why doesn't anybody care about apathy? From wlfraed at ix.netcom.com Sat Jul 31 15:46:05 2021 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sat, 31 Jul 2021 15:46:05 -0400 Subject: 'Pygame Module' not working References: Message-ID: On Sat, 31 Jul 2021 14:07:05 +0530, 37_VA_VEER CHAKRABORTY declaimed the following: >pygame.image.load('assets/Flappy Bird.png') >However, when I ran the script it was showing an error message - File not >found >Please advise me on how to upload the sprites and where I was going wrong. First attempt: use a full pathname. Second: determine what the "current working directory" is in which your program is running, then use a pathname relative to that directory. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From python at mrabarnett.plus.com Sat Jul 31 16:36:12 2021 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 31 Jul 2021 21:36:12 +0100 Subject: 'Pygame Module' not working In-Reply-To: References: Message-ID: On 2021-07-31 20:46, Dennis Lee Bieber wrote: > On Sat, 31 Jul 2021 14:07:05 +0530, 37_VA_VEER CHAKRABORTY > declaimed the following: > >>pygame.image.load('assets/Flappy Bird.png') >>However, when I ran the script it was showing an error message - File not >>found >>Please advise me on how to upload the sprites and where I was going wrong. > > First attempt: use a full pathname. > > Second: determine what the "current working directory" is in which your > program is running, then use a pathname relative to that directory. > The path of the program itself should be in __file__. You can then use os.path.dirname to get the path of its folder and os.path.join to build a path from that to the image file.