Re: Files can only be modified in IDLE, but not via Powershell
On 08/02/2021 22:33, Stefan Ritter wrote: Hi, It would be highly appreciated if you could offer me some advice to solve a problem I'm currently facing: I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop. I wrote some code to insert text in a .txt-file. It works perfectly on my laptop. On my desktop it works only if i run it in IDLE, the text appears afterwards in the file . However it does not work if run it in Powershell (or anything else), there are no changes made in the file. I do not understand why this is the case. Python version, installation paths and user are the same on desktop and laptop. I searched a bit and found out that this issue might be caused by my antivirus software comodo, but even after I replaced it with antivir, an reinstalled python this didn't change anything. As mentionned, any help is highly appreciated. If you need any additional information please let me know! My crystal ball says Idle and the shell use different working directories; you have a relative path, change one file and are looking at the other. If that's not the case -- show us the code. If there is an error message and a traceback provide that, too. Use copy-and-paste for both code and error. -- https://mail.python.org/mailman/listinfo/python-list
Re: Files can only be modified in IDLE, but not via Powershell
On 2/8/2021 4:33 PM, Stefan Ritter wrote: Hi, It would be highly appreciated if you could offer me some advice to solve a problem I'm currently facing: I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop. I wrote some code to insert text in a .txt-file. It works perfectly on my laptop. On my desktop it works only if i run it in IDLE, the text appears afterwards in the file . However it does not work if run it in Powershell (or anything else), there are no changes made in the file. Find the minimum code that exhibits a behavior difference. It should be short enough to post here, along with the command you used to run it in PowerShell or CommandPrompt and how you ran it in IDLE. I do not understand why this is the case. Python version, installation paths and user are the same on desktop and laptop. I searched a bit and found out that this issue might be caused by my antivirus software comodo, but even after I replaced it with antivir, an reinstalled python this didn't change anything. As mentionned, any help is highly appreciated. If you need any additional information please let me know! Best regards, Stefan -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Inconveniente
*Buenas tardes, le escribo breve y puntualmente para reportar este el siguiente error al cual no le pude dar solución.* *Instalé Python 3.9.1 (64 bits), todo había funcionado bien hasta que necesité usar la librería seaborn. Al ejecutar mi algoritmo obtenía el siguiente error: * (...\Python\Python39\site-packages\matplotlib\__init__.py) * Desinstalé python, lo reinstalé. * Instale diversas versiones de Matpltlib * Desinstalé seaborn, lo reinstalé. Busque soluciones en la página oficial, foros como:Stack Overflow, reddit, etc y no pudé dar con la solución para esta versión de python. Al final instalé python 3.8 de 32 bits, con las librerías que necesitaba, y logré realizar el trabajó. Mi OS es Windows 10, 64 bits. Sin más por el momento, me despido cordialmente. -- https://mail.python.org/mailman/listinfo/python-list
Re: Files can only be modified in IDLE, but not via Powershell
On 08/02/2021 21:33, Stefan Ritter wrote: > I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop. So notionally identical. > I wrote some code to insert text in a .txt-file. It works perfectly on > my laptop. > > On my desktop it works only if i run it in IDLE, the text appears > afterwards in the file . However it does not work if run it in > Powershell (or anything else), there are no changes made in the file. You only mention powershell in the context of the desktop. How are you running the code. Can you show us the command line for both laptop and desktop? Or describe exactly what you are doing if using a GUI tool. Showing us the code may help too! -- 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 -- https://mail.python.org/mailman/listinfo/python-list
UTF-16 or something else?
I downloaded US hospital ICU capacity data this morning from this page: https://healthdata.gov/dataset/covid-19-reported-patient-impact-and-hospital-capacity-facility (The download link is about halfway down the page.) Trying to read it using my personal CSV tools without specifying an encoding, it failed to understand the first column, hospital_pk. That is apparently because the file isn't simply ASCII or UTF-8. There are a few bytes ahead of the "h". However, if I open the file using "utf-16" as the encoding, Python complains there is no BOM. od(1) suggests there is *something* ahead of the first column name, but it's three bytes, not two: % od -A x -t x1z -v < reported_hospital_capacity_admissions_facility_level_weekly_average_timeseries_20210207.csv | head 00 *ef bb bf* 68 6f 73 70 69 74 61 6c 5f 70 6b 2c 63 >...hospital_pk,c< 10 6f 6c 6c 65 63 74 69 6f 6e 5f 77 65 65 6b 2c 73 >ollection_week,s< 20 74 61 74 65 2c 63 63 6e 2c 68 6f 73 70 69 74 61 >tate,ccn,hospita< ... I'm opening the file like so: inf = open(args[0], "r", encoding=encoding) where encoding is passed on the command line. I know I can simply edit out those bytes and probably be good-to-go, but I'd prefer not to. What should I be passing for the encoding? Skip, who thought everybody had effectively settled on utf-8 at this point, but apparently not... -- https://mail.python.org/mailman/listinfo/python-list
Troubles with Python imports
Hello, I’ve just typed „pip install selenium“ into my command prompt on windows 10. Although my computer told me that the requirement was already satisfied, import selenium did not work. So I tried different methods to install it and typed „Python“ in my command prompt and imported selenium. It worked fine. Then, I typed it into my shell and got an error. Why is it working in the command prompt but not in the actual shell? -- https://mail.python.org/mailman/listinfo/python-list
Re: UTF-16 or something else?
Try setting encoding to: "utf-8-sig". 'eb bb bf' is the byte order mark for UTF8 (most systems do not include this in UTF-8 encoded files) Python will correctly read UTF8 BOMs if you use the 'utf-8-sig' encoding when reading files Steve On Tue, Feb 9, 2021 at 2:56 PM Skip Montanaro wrote: > I downloaded US hospital ICU capacity data this morning from this page: > > > https://healthdata.gov/dataset/covid-19-reported-patient-impact-and-hospital-capacity-facility > > (The download link is about halfway down the page.) > > Trying to read it using my personal CSV tools without specifying an > encoding, it failed to understand the first column, hospital_pk. That is > apparently because the file isn't simply ASCII or UTF-8. There are a few > bytes ahead of the "h". However, if I open the file using "utf-16" as the > encoding, Python complains there is no BOM. od(1) suggests there is > *something* ahead of the first column name, but it's three bytes, not two: > > % od -A x -t x1z -v < > > reported_hospital_capacity_admissions_facility_level_weekly_average_timeseries_20210207.csv > | head > 00 *ef bb bf* 68 6f 73 70 69 74 61 6c 5f 70 6b 2c 63 > >...hospital_pk,c< > 10 6f 6c 6c 65 63 74 69 6f 6e 5f 77 65 65 6b 2c 73 >ollection_week,s< > 20 74 61 74 65 2c 63 63 6e 2c 68 6f 73 70 69 74 61 >tate,ccn,hospita< > ... > > I'm opening the file like so: > > inf = open(args[0], "r", encoding=encoding) > > where encoding is passed on the command line. I know I can simply edit out > those bytes and probably be good-to-go, but I'd prefer not to. What should > I be passing for the encoding? > > Skip, who thought everybody had effectively settled on utf-8 at this point, > but apparently not... > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Mutable defaults
Most of us know of the perils of mutable default values. So I came up with the following proof of concept: from inspect import signature as signature_of, Parameter from itertools import zip_longest from copy import copy def copy_defaults(f): signature = signature_of(f) def wrapper(*args): newargs = [] for argument, parameter_item in zip_longest(args, signature.parameters.items(), fillvalue = Parameter.empty): _, parameter = parameter_item if argument is not Parameter.empty: newargs.append(argument) elif (parameter.default is not Parameter.empty): newargs.append(copy(parameter.default)) else: raise TypeError("Not enough arguments") return f(*newargs) return wrapper @copy_defaults def prepare(value, lst = []): for vl in range(value): lst.append(vl) return lst print(prepare(2)) print(prepare(3)) Running the above will produce: [0, 1] [0, 1, 2] -- https://mail.python.org/mailman/listinfo/python-list
Re: UTF-16 or something else?
On 2021-02-09, Skip Montanaro wrote: > I downloaded US hospital ICU capacity data this morning from this page: > > https://healthdata.gov/dataset/covid-19-reported-patient-impact-and-hospital-capacity-facility > > (The download link is about halfway down the page.) > > Trying to read it using my personal CSV tools without specifying an > encoding, it failed to understand the first column, hospital_pk. That is > apparently because the file isn't simply ASCII or UTF-8. There are a few > bytes ahead of the "h". However, if I open the file using "utf-16" as the > encoding, Python complains there is no BOM. od(1) suggests there is > *something* ahead of the first column name, but it's three bytes, not two: > > % od -A x -t x1z -v < > reported_hospital_capacity_admissions_facility_level_weekly_average_timeseries_20210207.csv >| head > 00 *ef bb bf* 68 6f 73 70 69 74 61 6c 5f 70 6b 2c 63 >...hospital_pk,c< > 10 6f 6c 6c 65 63 74 69 6f 6e 5f 77 65 65 6b 2c 73 >ollection_week,s< > 20 74 61 74 65 2c 63 63 6e 2c 68 6f 73 70 69 74 61 >tate,ccn,hospita< > ... It's UTF-8 with a UTF-16 BOM prepended, which is not uncommon when you have a file that's been converted to UTF-8 from UTF-16 or has been produced by shitty Microsoft software. You can tell instantly at a glance that it's not UTF-16 because the ascii dump would l.o.o.k. .l.i.k.e. .t.h.i.s. You can decode it as utf-8 and ignore the BOM character, or as someone else has rightly said, Python can decode it as utf-8-sig, which does that automatically for you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Mutable defaults
On Wed, Feb 10, 2021 at 2:19 AM Antoon Pardon wrote: > > Most of us know of the perils of mutable default values. So I came up with > the following proof of concept: > > def copy_defaults(f): > > def wrapper(*args): > return f(*newargs) > return wrapper > > @copy_defaults > def prepare(value, lst = []): > for vl in range(value): > lst.append(vl) > return lst > > print(prepare(2)) > print(prepare(3)) > > Running the above will produce: > > [0, 1] > [0, 1, 2] > Nice idea, but you've limited your functions to positional-only parameters. Extending this to support keyword arguments is a lot harder, and is why it's generally easier to use standard idioms like defaulting to None (or to a unique object) and then "if lst is None: lst = []" at the start of the function. Have you considered inspect.signature and its various methods? It may be useful here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Mutable defaults
On 09/02/2021 16:17, Antoon Pardon wrote: Most of us know of the perils of mutable default values. So I came up with the following proof of concept: [...] def copy_defaults(f): Once you know you need that decorator you won't need it anymore ;) @copy_defaults def prepare(value, lst = []): for vl in range(value): lst.append(vl) return lst print(prepare(2)) print(prepare(3)) Running the above will produce: [0, 1] [0, 1, 2] Because of @copy_defaults def prepare(value, lst=[[]]): for vl in range(value): lst[0].append(vl) return lst you may consider changing it to deepcopy_defaults. -- https://mail.python.org/mailman/listinfo/python-list
Re: Troubles with Python imports
On 2/9/21 7:55 AM, Philipp Daher via Python-list wrote: Hello, I’ve just typed „pip install selenium“ into my command prompt on windows 10. Although my computer told me that the requirement was already satisfied, import selenium did not work. So I tried different methods to install it and typed „Python“ in my command prompt and imported selenium. It worked fine. Then, I typed it into my shell and got an error. Why is it working in the command prompt but not in the actual shell? This isn't really making sense - what do you consider to be the difference between "the command prompt" and "the actual shell"? When you run the python program from a command line (cmd.exe or PowerShell), what you get is the Python interpreter, or shell, or whatever you want to call it. You said things worked there - so the installation is fine. Now what does "Then, I typed it into my shell and got an error" mean? If you mean you typed "import selenium" in cmd.exe, why would you expect that to work? The import is an instruction to Python... Please explain further so we can try to help. -- https://mail.python.org/mailman/listinfo/python-list
Re: UTF-16 or something else?
> > Try setting encoding to: "utf-8-sig". > > 'eb bb bf' is the byte order mark for UTF8 (most systems do not include > this in UTF-8 encoded files) > > Python will correctly read UTF8 BOMs if you use the 'utf-8-sig' encoding > when reading files > Excellent, thanks. That worked like a charm. Knowing what its called also allowed me to look up more info. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: UTF-16 or something else?
> > It's UTF-8 with a UTF-16 BOM prepended, which is not uncommon when you > have a file that's been converted to UTF-8 from UTF-16 or has been > produced by shitty Microsoft software. You can tell instantly at a > glance that it's not UTF-16 because the ascii dump would l.o.o.k. > .l.i.k.e. .t.h.i.s. > Ah, right. Been a long, long while (well before Unicode was a thing) since I needed to use od(1) and don't remember dealing with UTF-16 before. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Files can only be modified in IDLE, but not via Powershell
On Mon, Feb 8, 2021 at 4:22 PM Stefan Ritter wrote: > > Hi, > > It would be highly appreciated if you could offer me some advice to > solve a problem I'm currently facing: > > afterwards in the file . However it does not work if run it in > Powershell (or anything else), there are no changes made in the file. > > I do not understand why this is the case. Python version, installation > paths and user are the same on desktop and laptop. I searched a bit and > found out that this issue might be caused by my antivirus software > comodo, but even after I replaced it with antivir, an reinstalled python > this didn't change anything. > > As mentionned, any help is highly appreciated. If you need any > additional information please let me know! > It's probably either two different paths, or an ignored traceback. Please cut and paste the output of your script - one paste for the working output, and one for the nonworking output. You may want to use os.path.abspath(*path*) on your path, and print it to the screen. Then compare that to Resolve-Path pathname in Powershell. HTH References: https://docs.python.org/3/library/os.path.html https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/resolve-path?view=powershell-7.1 -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Inconveniente
On 09/02/2021 15.13, Juan Jose Reyna Figuera wrote: > *Buenas tardes, le escribo breve y puntualmente para reportar este el > siguiente error al cual no le pude dar solución.* > > *Instalé Python 3.9.1 (64 bits), todo había funcionado bien hasta que > necesité usar la librería seaborn. Al ejecutar mi algoritmo obtenía el > siguiente error: * > > (...\Python\Python39\site-packages\matplotlib\__init__.py) > > * Desinstalé python, lo reinstalé. > * Instale diversas versiones de Matpltlib > * Desinstalé seaborn, lo reinstalé. > > Busque soluciones en la página oficial, foros como:Stack Overflow, reddit, > etc y no pudé dar con la solución para esta versión de python. > > Al final instalé python 3.8 de 32 bits, con las librerías que necesitaba, y > logré realizar el trabajó. > > Mi OS es Windows 10, 64 bits. > > Sin más por el momento, > > me despido cordialmente. Well done for solving the problem! [ Translation: matplotlib (and seaborn) not playing-nicely with Python 3.9 64-bit edition on MS-Win 10. Solved by down-grading to Python 3.8 32-bit. ] Yes, there have been problems with certain libraries that have not (yet) been updated to run on Python 3.9. Your solution is the current advice. However, I'm concerned about mathematical applications on 32-bit platforms. Did you try Python 3.8's 64-bit option (plus libraries)? NB this is an English-language list - for faster response to questions. [Cordialmente] -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Files can only be modified in IDLE, but not via Powershell
Thanks for your advice! To be honest i'm not quite sure what did the trick, I just played a little bit around with the paths. Anyway, now its working as expected. Bless your crystal ball! Needless to say: Many thanks for all the other responses i did receive! Am 09.02.2021 um 10:50 schrieb Peter Otten: On 08/02/2021 22:33, Stefan Ritter wrote: Hi, It would be highly appreciated if you could offer me some advice to solve a problem I'm currently facing: I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop. I wrote some code to insert text in a .txt-file. It works perfectly on my laptop. On my desktop it works only if i run it in IDLE, the text appears afterwards in the file . However it does not work if run it in Powershell (or anything else), there are no changes made in the file. I do not understand why this is the case. Python version, installation paths and user are the same on desktop and laptop. I searched a bit and found out that this issue might be caused by my antivirus software comodo, but even after I replaced it with antivir, an reinstalled python this didn't change anything. As mentionned, any help is highly appreciated. If you need any additional information please let me know! My crystal ball says Idle and the shell use different working directories; you have a relative path, change one file and are looking at the other. If that's not the case -- show us the code. If there is an error message and a traceback provide that, too. Use copy-and-paste for both code and error. -- https://mail.python.org/mailman/listinfo/python-list
Re: Response for PING in ircbot.
‐‐‐ Original Message ‐‐‐ On Saturday, January 30, 2021 11:50 AM, Bischoop wrote: > Got problem with responding for Ping, > tried so many ways to response > and always end up with time out or other error. > This time: > Is it possible to share your final Ping answer with the list? I've had a long term Flask/Python issue where the site just dies. (MY) External ping attempts still report the Flask site is functioning; but accessing the pages returns 500 errors. Apache is still running and other (non-Flask) sites are still running on the Linux server. I see no errors that might be causing this under /var/log/*, or apache's error log; or the site's access/error logs. What I'd like to do is set up my own external monitor, to at least known WHEN the site has died. And I'm wondering if your PING might be better. Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Mutable defaults
On 2/9/2021 10:17 AM, Antoon Pardon wrote: Most of us know of the perils of mutable default values. So I came up with the following proof of concept: Which is intended to do what? from inspect import signature as signature_of, Parameter from itertools import zip_longest from copy import copy def copy_defaults(f): Docstring? signature = signature_of(f) def wrapper(*args): newargs = [] for argument, parameter_item in zip_longest(args, signature.parameters.items(), fillvalue = Parameter.empty): _, parameter = parameter_item if argument is not Parameter.empty: newargs.append(argument) elif (parameter.default is not Parameter.empty): newargs.append(copy(parameter.default)) else: raise TypeError("Not enough arguments") return f(*newargs) return wrapper @copy_defaults def prepare(value, lst = []): for vl in range(value): lst.append(vl) return lst print(prepare(2)) print(prepare(3)) Running the above will produce: [0, 1] [0, 1, 2] -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Inconveniente
This is an English list. There are Spanish lists, such as Esto es lista engleis. Hai listas espanolas. https://mail.python.org/mailman/listinfo/python-es On 2/8/2021 9:13 PM, Juan Jose Reyna Figuera wrote: *Buenas tardes, le escribo breve y puntualmente para reportar este el siguiente error al cual no le pude dar solución.* *Instalé Python 3.9.1 (64 bits), todo había funcionado bien hasta que necesité usar la librería seaborn. Al ejecutar mi algoritmo obtenía el siguiente error: * (...\Python\Python39\site-packages\matplotlib\__init__.py) When asking about errors, copy and paste entire traceback. Cuando pidiendo cerca de errores, 'copy and paste' todo 'traceback'. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
installation issues
Hello, My name is Martin Lopez. I just downloaded Python 3.9.1 (64 bit) Setup. After I install the program then try to run it, with no success. I've uninstalled all previous versions and reinstalled them, but it does not seem to help. Can you please assist? Thank you, -- https://mail.python.org/mailman/listinfo/python-list
Re: Troubles with Python imports
On 2/9/2021 9:55 AM, Philipp Daher via Python-list wrote: Hello, I’ve just typed „pip install selenium“ into my command prompt on windows 10. Although my computer told me that the requirement was already satisfied, import selenium did not work. So I tried different methods to install it and typed „Python“ in my command prompt and imported selenium. It worked fine. Then, I typed it into my shell and got an error. Why is it working in the command prompt but not in the actual shell? One common problem (and answer -- monthy on stackoverflow) is that you have more than one python binary installed; do not have module xyz installed for all of them; and are running different binaries to get the different responses. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Inconveniente
On 2/9/2021 3:39 PM, dn via Python-list wrote: On 09/02/2021 15.13, Juan Jose Reyna Figuera wrote: [ Translation: matplotlib (and seaborn) not playing-nicely with Python 3.9 64-bit edition on MS-Win 10. Solved by down-grading to Python 3.8 32-bit. ] Yes, there have been problems with certain libraries that have not (yet) been updated to run on Python 3.9. Your solution is the current advice. I checked that seaborn lists 3.9. To my surprise, matplotlib does not. If real, not good, and indeed, using 3.8 is the only solution. A traceback from matplotlib failing might have revealed the specific problem. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Python 3.9. 1 not working
Where do I inquire about installation support? -- https://mail.python.org/mailman/listinfo/python-list
Re: installation issues
On 10/02/2021 12.23, Martin Lopez wrote: > Hello, > > My name is Martin Lopez. I just downloaded Python 3.9.1 (64 bit) Setup. > > After I install the program then try to run it, with no success. > > I've uninstalled all previous versions and reinstalled them, but it does > not seem to help. > > Can you please assist? Welcome to the mailing list Martin! Please also note that there is a Python-Tutor list expressly for Python-learners. Answers vary according to which Operating System is in-use! Useful Web.Refs: https://wiki.python.org/moin/FrontPage (particularly the Beginner's Guide) https://www.python.org/doc/ (for everything, but start with "Using Python") -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list