Re: Persistent Error: Python was not found
On 8/13/22, Jonathan Owah wrote: > > I've been trying to configure my laptop to run python scripts. > This is the error I keep getting: > Python was not found; run without arguments to install from the Microsoft > Store, or disable this shortcut from Settings > Manage App Execution > Aliases. If you keep seeing this message, then the shell is finding and running Microsoft's default "python.exe" redirector app execution alias that's located in "%LocalAppData%\Microsoft\WindowsApps". By default, this directory is set at the beginning of the user "Path" value in the registry and thus takes precedence (but not over the system "Path"). Confirm this by running `where.exe python`. An app execution alias is a special type of filesystem symbolic link to a store app's executable. These aliases are created in a user's "%LocalAppData%\Microsoft\WindowsApps" directory. Store apps themselves are usually installed in "%ProgramFiles%\WindowsApps", which is a system managed directory that even administrators can't easily modify (and shouldn't modify). Each user on a system has their own set of installed store apps, even though the apps are installed only once at the system level. By default, Windows creates "python.exe" and "python3.exe" aliases for the "App Installer" PythonRedirector app. In the alias manager, these two will be clearly listed as aliases for "App Installer". If you run this redirector app with one or more command-line arguments, it will print the above quoted message to the console. If the redirector app is run without arguments, it will open the Microsoft Store to install the latest version of the Python store app distribution. Currently that means Python 3.10. In my experience, the app execution alias manager component of Windows is unreliable. A disabled alias might still exist in "%LocalAppData%\Microsoft\WindowsApps", or an old alias might be left in place when an app is installed. Once the real Python store app is installed, go back into the alias manager and toggle the "python.exe" and "python3.exe" aliases off and back on. If that doesn't resolve the problem, manually delete the "python.exe" and "python3.exe" aliases from "%LocalAppData%\Microsoft\WindowsApps". Then toggle them off and on again in the alias manager. Hopefully they'll be created to correctly alias the real Python app instead of the "App Installer" redirector. -- https://mail.python.org/mailman/listinfo/python-list
Re: Persistent Error: Python was not found
Thank you so much for your assistance . The fault was actually mine: I was running a command with python3, instead of just python. python3 works for Mac, but not Windows. I'm fairly new to Python so I was just following along a tutorial, and I didn't take note of the fact that the command didn't work because the tutorial was done on a MacBook, while I'm using a Windows device. Thanks for your help, Regards On Mon, Aug 15, 2022 at 8:14 AM Eryk Sun wrote: > On 8/13/22, Jonathan Owah wrote: > > > > I've been trying to configure my laptop to run python scripts. > > This is the error I keep getting: > > Python was not found; run without arguments to install from the Microsoft > > Store, or disable this shortcut from Settings > Manage App Execution > > Aliases. > > If you keep seeing this message, then the shell is finding and running > Microsoft's default "python.exe" redirector app execution alias that's > located in "%LocalAppData%\Microsoft\WindowsApps". By default, this > directory is set at the beginning of the user "Path" value in the > registry and thus takes precedence (but not over the system "Path"). > Confirm this by running `where.exe python`. > > An app execution alias is a special type of filesystem symbolic link > to a store app's executable. These aliases are created in a user's > "%LocalAppData%\Microsoft\WindowsApps" directory. Store apps > themselves are usually installed in "%ProgramFiles%\WindowsApps", > which is a system managed directory that even administrators can't > easily modify (and shouldn't modify). Each user on a system has their > own set of installed store apps, even though the apps are installed > only once at the system level. > > By default, Windows creates "python.exe" and "python3.exe" aliases for > the "App Installer" PythonRedirector app. In the alias manager, these > two will be clearly listed as aliases for "App Installer". If you run > this redirector app with one or more command-line arguments, it will > print the above quoted message to the console. If the redirector app > is run without arguments, it will open the Microsoft Store to install > the latest version of the Python store app distribution. Currently > that means Python 3.10. > > In my experience, the app execution alias manager component of Windows > is unreliable. A disabled alias might still exist in > "%LocalAppData%\Microsoft\WindowsApps", or an old alias might be left > in place when an app is installed. Once the real Python store app is > installed, go back into the alias manager and toggle the "python.exe" > and "python3.exe" aliases off and back on. If that doesn't resolve the > problem, manually delete the "python.exe" and "python3.exe" aliases > from "%LocalAppData%\Microsoft\WindowsApps". Then toggle them off and > on again in the alias manager. Hopefully they'll be created to > correctly alias the real Python app instead of the "App Installer" > redirector. > -- https://mail.python.org/mailman/listinfo/python-list
Re: Persistent Error: Python was not found
On 8/15/22, Jonathan Owah wrote: > Thank you so much for your assistance . > > The fault was actually mine: I was running a command > with python3, instead of just python. > python3 works for Mac, but not Windows. If the Python 3.10 store app is installed with all aliases enabled, then "python", "python3", and "python3.10" all work. The standard distribution from python.org, on the other hand, only has a "python" executable. -- https://mail.python.org/mailman/listinfo/python-list
Re: Exclude 'None' from list comprehension of dicts
Op 5/08/2022 om 07:50 schreef Loris Bennett: Antoon Pardon writes: Op 4/08/2022 om 13:51 schreef Loris Bennett: Hi, I am constructing a list of dictionaries via the following list comprehension: data = [get_job_efficiency_dict(job_id) for job_id in job_ids] However, get_job_efficiency_dict(job_id) uses 'subprocess.Popen' to run an external program and this can fail. In this case, the dict should just be omitted from 'data'. I can have 'get_job_efficiency_dict' return 'None' and then run filtered_data = list(filter(None, data)) but is there a more elegant way? Just wondering, why don't you return an empty dictionary in case of a failure? In that case your list will be all dictionaries and empty ones will be processed fast enough. When the list of dictionaries is processed, I would have to check each element to see if it is empty. That strikes me as being less efficient than filtering out the empty dictionaries in one go, although obviously one would need to benchmark that. I may be missing something but why would you have to check each element to see if it is empty? What would go wrong if you just treated empty dictionaries the same as non-empty directories? -- Antoon Pardon. -- https://mail.python.org/mailman/listinfo/python-list
Re: Persistent Error: Python was not found
Eryk Sun wrote: If the redirector app is run without arguments, it will open the Microsoft Store to install the latest version of the Python store app distribution. Currently that means Python 3.10. That is true with cmd. But with a shell like 4NT, I get: c:\> "%LocalAppData%\Microsoft\WindowsApps\python.exe" 4NT: (Sys) No access to the file. "C:\Users\gvane\AppData\Local\Microsoft\WindowsApps\python.exe" No matter what I do with this "App Alias" setting. What a broken and confusing design this AppX design is. -- --gv -- https://mail.python.org/mailman/listinfo/python-list
Re: Persistent Error: Python was not found
On Mon, 15 Aug 2022 14:38:25 +1000, Mike Dewhirst declaimed the following: >If you want to execute a python script without first opening a cmd >prompt, you need a bat file or shortcut which contains the command line >you want executed. Give that a double-click and it should also work. > I've never had to do that... But I have file associations set up so that .py is considered to be an executable file. Just double-clicking on the file will run it. The problem is that it will open a command shell, run, and then close the command shell UNLESS one explicitly codes some sort of "hold" at the end of the program jnk = input("Press return to exit") .pyw extension does not open the command shell -- but is meant for programs that use one of the various GUI frameworks, which is probably more than the new-comer is ready to attack. -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Parallel(?) programming with python
I would like to thank everybody who answered my question. The insight was very informative. This seems to be one of the few newsgroups still alive and kicking, with a lot of knowledgeable people taking the time to help others. I like how quick and easy it is to post questions and receive answers here as compared to web-based forums (although there are some disadvantages too). I'm implementing some of the ideas received here and I will surely have other questions as I go. But the project will take a long time because I'm doing this as a hobby during my vacation, that are unfortunately about to end. Thanks again, Community. On 08.08.22 12:47, Andreas Croci wrote: tI would like to write a program, that reads from the network a fixed amount of bytes and appends them to a list. This should happen once a second. Another part of the program should take the list, as it has been filled so far, every 6 hours or so, and do some computations on the data (a FFT). Every so often (say once a week) the list should be saved to a file, shorthened in the front by so many items, and filled further with the data coming fom the network. After the first saving of the whole list, only the new part (the data that have come since the last saving) should be appended to the file. A timestamp is in the data, so it's easy to say what is new and what was already there. I'm not sure how to do this properly: can I write a part of a program that keeps doing its job (appending data to the list once every second) while another part computes something on the data of the same list, ignoring the new data being written? Basically the question boils down to wether it is possible to have parts of a program (could be functions) that keep doing their job while other parts do something else on the same data, and what is the best way to do this. -- https://mail.python.org/mailman/listinfo/python-list
Re: Persistent Error: Python was not found
On 8/15/22, Gisle Vanem via Python-list wrote: > Eryk Sun wrote: > >> If the redirector app >> is run without arguments, it will open the Microsoft Store to install >> the latest version of the Python store app distribution. Currently >> that means Python 3.10. > > That is true with cmd. But with a shell like 4NT, I get: >c:\> "%LocalAppData%\Microsoft\WindowsApps\python.exe" >4NT: (Sys) No access to the file. > "C:\Users\gvane\AppData\Local\Microsoft\WindowsApps\python.exe" > > No matter what I do with this "App Alias" setting. > What a broken and confusing design this AppX design is. An app execution alias is a reparse point with the tag IO_REPARSE_TAG_APPEXECLINK (0x801B). Neither the I/O manager no any driver in the kernel supports this type of reparse point. For better or worse, this is intentional. As such, if CreateFileW() is called on an alias without using the flag FILE_FLAG_OPEN_REPARSE_POINT, the attempt to traverse the link fails with ERROR_CANT_ACCESS_FILE (1920). Note that Python's os.stat() was updated to open the reparse point directly in this case instead of failing. But a lot of applications, in particular non-Microsoft shells such as MSYS bash (and apparently 4NT) haven't been updated similarly. Even if the link could be traversed, the target file under "%ProgramFiles%\WindowsApps" doesn't grant execute access to users unless they have an access token that includes a WIN://SYSAPPID attribute that corresponds to the executed app. How this works in practice when executing an app is that CreateProcessW() handles ERROR_CANT_ACCESS_FILE by opening the reparse point, reading the relevant app information, and creating a custom access token that allows it to execute the app directly via the internal equivalent of CreateProcessAsUserW(). -- https://mail.python.org/mailman/listinfo/python-list
Re: Persistent Error: Python was not found
On 8/15/22, Dennis Lee Bieber wrote: > > Just double-clicking on the file will run it. The problem is that it > will open a command shell, run, and then close the command shell UNLESS one > explicitly codes some sort of "hold" at the end of the program The console window is a terminal, not a shell. If an application is flagged as a console app, as is "python.exe", and the process doesn't inherit a console, the initialization code in kernelbase.dll allocates a new console session. This could be implemented by the classic conhost.exe host, or, in Windows 11, by an openconsole.exe session that's associated with a tab in Windows Terminal. If it's the latter, Terminal can be configured to keep a tab open after the console session has ended. The tab will display the exit status of the process that allocated the console session. -- https://mail.python.org/mailman/listinfo/python-list
Problem using cx_Freeze
I’m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: AttributeError: module 'cx_Freeze' has no attribute ‘BdistDMG’ I’m using Anaconda and error appears with the import command: from cx_Freeze import * From the terminal the command: python setup.py build gives much the same error. I believe there is an issue specifying the output file name but don’t know how to resolve it. Any suggestions, thanks. David -- https://mail.python.org/mailman/listinfo/python-list
Re: Python getting problem of installing pyqt5
On 8/13/22 09:32, Varad Gore wrote: Looks like you have a version mismatch problem. > Collecting pyqt5 > Using cached PyQt5-5.15.7-cp37-abi3-win_amd64.whl (6.8 MB) > Requirement already satisfied: PyQt5-Qt5>=5.15.0 in > c:\users\gorev\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages > (from pyqt5) (5.15.2) > Requirement already satisfied: PyQt5-sip<13,>=12.11 in > c:\users\gorev\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages > (from pyqt5) (12.11.0) > Installing collected packages: pyqt5 > WARNING: The scripts pylupdate5.exe, pyrcc5.exe and pyuic5.exe are > installed in > 'C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' > which is not on PATH. > Consider adding this directory to PATH or, if you prefer to suppress this > warning, use --no-warn-script-location. > Successfully installed pyqt5-5.15.7 So far, so good... but then it goes bad. > (venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> ^C > (venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> pip install pyqt5-tools > Collecting pyqt5-tools > Using cached pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) > Collecting pyqt5==5.15.4 > Using cached PyQt5-5.15.4.tar.gz (3.3 MB) > Installing build dependencies ... done > Getting requirements to build wheel ... done > Preparing metadata (pyproject.toml) ... error > error: subprocess-exited-with-error > > × Preparing metadata (pyproject.toml) did not run successfully. This apparently depends on a *different* version of pyqt5 which does not have a compatible binary (compiled) wheel available, so the installer process is going to try to build it for you. This rarely works on Windows - you usually have to have some very precise setup - that is, you have to be *planning* to build it, the convenience build-because-didn't-find-wheel is very likely doomed to failure for anything complex. The pyqt5-tools package has not been updated for a year now, several drops of pyqt5 have happened since, according to the history on pypi.org. I'm assuming -tools are pnned to the same version of pyqt5, but this is only a guess, could be some other mismatch. Looks like there's an issue filed on this: https://github.com/altendky/pyqt-tools/issues/106 -- https://mail.python.org/mailman/listinfo/python-list
Re: Python getting problem of installing pyqt5
On Sat, 13 Aug 2022 08:32:19 -0700 (PDT), Varad Gore declaimed the following: >Collecting pyqt5 > Using cached PyQt5-5.15.7-cp37-abi3-win_amd64.whl (6.8 MB) Where did this one come from? The "cp37" seems to imply it is a Python 3.7 variant. You also didn't include the command line that started this sequence... >(venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> ^C ... was it also run from inside the virtual environment? >(venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> pip install pyqt5-tools Personally, anytime I see OneDrive involved, my first thought is to blame it (It plays hob with multi-file relational databases, such as Visual FoxPro used by the TMG genealogy program -- VFP opens/closes table files (there are three per table) on an as-needed scheme; OneDrive sees a modified file and locks it while synching it to the cloud -- and that blocks VFP from being able to do the next update, and often causing corruption of the database when the three table files become unsynchronized). However... as a test (note: I have Python (an older ActiveState build) installed "for all users", and not in a user specific install. C:\Users\Wulfraed>pip install pyqt5_tools Collecting pyqt5_tools Downloading pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) Collecting pyqt5-plugins<5.15.4.3,>=5.15.4.2.2 Downloading pyqt5_plugins-5.15.4.2.2-cp38-cp38-win_amd64.whl (67 kB) || 67 kB 988 kB/s Collecting python-dotenv Downloading python_dotenv-0.20.0-py3-none-any.whl (17 kB) Collecting pyqt5==5.15.4 Downloading PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl (6.8 MB) || 6.8 MB 541 kB/s >>>NOTE the file name for PyQt5 Requirement already satisfied: click in c:\python38\lib\site-packages (from pyqt5_tools) (7.1.2) Collecting qt5-tools<5.15.2.2,>=5.15.2.1.2 Downloading qt5_tools-5.15.2.1.2-py3-none-any.whl (13 kB) Collecting PyQt5-Qt5>=5.15 Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB) || 50.1 MB 25 kB/s Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\python38\lib\site-packages (from pyqt5==5.15.4->pyqt5_tools) (12.8.1) Collecting qt5-applications<5.15.2.3,>=5.15.2.2.2 Downloading qt5_applications-5.15.2.2.2-py3-none-win_amd64.whl (60.9 MB) || 60.9 MB 5.5 kB/s Installing collected packages: PyQt5-Qt5, pyqt5, qt5-applications, qt5-tools, pyqt5-plugins, python-dotenv, pyqt5-tools Attempting uninstall: pyqt5 Found existing installation: PyQt5 5.15.1 Uninstalling PyQt5-5.15.1: Successfully uninstalled PyQt5-5.15.1 Successfully installed PyQt5-Qt5-5.15.2 pyqt5-5.15.4 pyqt5-plugins-5.15.4.2.2 pyqt5-tools-5.15.4.3.2 python-dotenv-0.20.0 qt5-applications-5.15.2.2.2 qt5-tools-5.15.2.1.2 C:\Users\Wulfraed> -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list
RE: Problem using cx_Freeze
I see a class called BdistDMG in the module called bdist_mac.py. Did you try importing that from cx_freeze? -Original Message- From: Python-list On Behalf Of David at Booomer Sent: Monday, August 15, 2022 11:31 AM To: python-list@python.org Subject: Problem using cx_Freeze I’m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: AttributeError: module 'cx_Freeze' has no attribute ‘BdistDMG’ I’m using Anaconda and error appears with the import command: from cx_Freeze import * From the terminal the command: python setup.py build gives much the same error. I believe there is an issue specifying the output file name but don’t know how to resolve it. Any suggestions, thanks. David -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Exclude 'None' from list comprehension of dicts
On 16/08/2022 00.56, Antoon Pardon wrote: > Op 5/08/2022 om 07:50 schreef Loris Bennett: >> Antoon Pardon writes: >> >>> Op 4/08/2022 om 13:51 schreef Loris Bennett: Hi, I am constructing a list of dictionaries via the following list comprehension: data = [get_job_efficiency_dict(job_id) for job_id in job_ids] However, get_job_efficiency_dict(job_id) uses 'subprocess.Popen' to run an external program and this can fail. In this case, the dict should just be omitted from 'data'. I can have 'get_job_efficiency_dict' return 'None' and then run filtered_data = list(filter(None, data)) but is there a more elegant way? >>> Just wondering, why don't you return an empty dictionary in case of a >>> failure? >>> In that case your list will be all dictionaries and empty ones will >>> be processed >>> fast enough. >> When the list of dictionaries is processed, I would have to check each >> element to see if it is empty. That strikes me as being less efficient >> than filtering out the empty dictionaries in one go, although obviously >> one would need to benchmark that. > > I may be missing something but why would you have to check each element > to see if it is empty? What would go wrong if you just treated empty > dictionaries the same as non-empty directories? 'Truthiness':- >>> bool( {} ) False >>> bool( { "a":1 } ) True -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem using cx_Freeze
This link covers how to use BDist_dmg. https://cx-freeze.readthedocs.io/en/latest/setup_script.html Sent from my iPhone > On Aug 15, 2022, at 12:11 PM, David at Booomer wrote: > > I’m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a > python app but running into an error message: > > AttributeError: module 'cx_Freeze' has no attribute ‘BdistDMG’ > > I’m using Anaconda and error appears with the import command: from cx_Freeze > import * > > From the terminal the command: python setup.py build gives much the same > error. > > I believe there is an issue specifying the output file name but don’t know > how to resolve it. > > Any suggestions, thanks. David > > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem using cx_Freeze
Hi Jim Thanks for your suggestions. I changed from cx_Freeze import * to from cx_Freeze import setup, Executable And no longer get the BdistDMG error — I had found the page https://cx-freeze.readthedocs.io/en/latest/setup_script.html But hadn’t tried the setup, Executable option in the from statement — However I now get an error init() takes from 2 to 12 positional arguments but 14 were given I found a couple instances of init in two .py files that were part of the whole. One .py file def __init__(self): Another .py file class Aboutwindow(QtGui.QMainWindow, Ui_Aboutwindow): def __init__(self,parent=None): QtGui.QMainWindow.__init__(self,parent) — class Main(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) When searching for this error the answers found suggested including self in the init parameter list but the code already has self. Thanks, David > On Aug 15, 2022, at 5:51 PM, Jim Schwartz wrote: > > This link covers how to use BDist_dmg. > > https://cx-freeze.readthedocs.io/en/latest/setup_script.html > > Sent from my iPhone > >> On Aug 15, 2022, at 12:11 PM, David at Booomer wrote: >> >> I’m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a >> python app but running into an error message: >> >> AttributeError: module 'cx_Freeze' has no attribute ‘BdistDMG’ >> >> I’m using Anaconda and error appears with the import command: from cx_Freeze >> import * >> >> From the terminal the command: python setup.py build gives much the same >> error. >> >> I believe there is an issue specifying the output file name but don’t know >> how to resolve it. >> >> Any suggestions, thanks. David >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem using cx_Freeze
On Mon, 15 Aug 2022 10:30:41 -0600, David at Booomer declaimed the following: >I’m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python >app but running into an error message: > >AttributeError: module 'cx_Freeze' has no attribute ‘BdistDMG’ What operating system? BdistDMG appears to be a Macintosh OS module -- something to do with disk images https://cx-freeze.readthedocs.io/en/latest/setup_script.html """ On Windows, you can build a simple installer containing all the files cx_Freeze includes for your application, by running the setup script as: python setup.py bdist_msi On Mac OS X, you can use bdist_dmg to build a Mac disk image. """ Note the command syntax and last line... -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list