i just install python 3.7 and also config the path.but when i type python in cmd its showing me "the application is unable to start correctly 0xc0000005"
The application was unable to start correctly (0xc0000005).click ok to close the Application
For me, this happened because ordinary users didn't have read+execute access on the following file:
C:\Windows\SysWOW64\api-ms-win-core-synch-l1-2-0.dll
This was discovered by running Sysinternals' Process Monitor to see what the Python3 thread was doing.
HTH
Related
How do you check if your script is already running to prevent it from running/opening multiple times.
I am aiming for it to either quit and allow the script to open again or stop the new one from running.
Using:
Python 3.8
Windows 10
File type .pyw
Ide: Thonny
I have looked and haven't been able to find a answer.
I want to debug an application using Python and Flask in VSCode. I have installed Flask and the app runs perfectly fine through cmd. But, when I try to debug it through VSCode, it gives the following error:
cd 'c:\Users\Aditi\CleanHandymanApp';
${env:FLASK_APP}='NewApp'; ${env:PYTHONIOENCODING}='UTF-8';
${env:PYTHONUNBUFFERED}='1'; & 'C:\Users\Aditi\envs\CleanHandymanApp\Scripts\python.exe'
'c:\Users\Aditi\.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py' '--client' '--host'
'localhost' '--port' '63143' '-m' 'flask' 'run' '--no-debugger' '--no-reload'
No module named flask
Can you please help me.
This error message can occur if you installed the python3 version of flask but Visual Studio Code tries to run your project with python2.
Make sure to select the correct version of python in the editor. This can be done by running the command Python: Select Interpreter from the Command Palette (Ctrl+Shift+P).
Activate your virtualenv and run
pip3 install -r requirements.txt
to reinstall all packages inside the venv.
For some reason VS Code thought I was missing all my packages the first time I debugged even though the app was running fine locally.
Sometimes you can get this error if you loaded Flask into a folder which has sub-files. For instance, if you loaded flask into the parent folder with the virtual shell instance but you're running your code in the child file (let's say parent is called crypto_files and inside that is a python source code file called blockchain.py ), then in order to get flask to run properly you'd have to run the file like this:
python crypto_files/blockchain.py
This allows your machine to see Flask running inside crypto_files but also run blockchain.py .
OR, it's possibly you could just reload Flask into the sub(child)file... blockchain.py and then you'd run it from within the subfile.
This complication is mainly due to modern "virtual instances" and shells which are basically like creating a virtual computer-machine inside your ACTUAL hard machine. Flask does this to avoid running everywhere, and since Flask is modular it allows each of your projects to run different modular configurations of Flask to suit each project precisely. The alternative would be awful: you'd have to load the fattest version of Flask with dozens of add-ons for each project, and so all your git and all your projects would have tons of extra code. Flask is built to be very small at the core to avoid this problem (too verbose!).
If you have installed flask in virtual environment, you should have activated it first.
source /path to env dir/bin/activate #in linux
workon 'name of env' #windows
Another option is add sys.path.append('d:/programas/anaconda3/lib/site-packages') in c:\Users\Aditi.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py
Being that "d:/programas/anaconda3/lib/site-packages" should be modified by your local python packages.
Use this command in the terminal instead of selecting run code:
python3 "insert your file name here without the quotes"
e.g.: python3 example.py
I had a variant of the issue mentioned by #confusius. I had installed both Python 3.9 and Python 3.10. I had added Flask to Python 3.10. I had been using one vscode workspace which had selected Python 3.10. I started another project in a different vscode workspace and it had selected Python 3.9 by default, which I didn't notice because I thought it would select the same Python I had already selected in the other workspace.
So I'm building a pretty simple service in python3.6. Client want's it to run on windows, so I'm using the win32serviceutil package to make a windows service. I install and package with pyinstaller and so far everything works great.
The issue I'm having is that the path differs between installing, starting and debugging. When installing and debugging, the path is the same as where I run the command from. When starting the service however, the path is C:/windows/system32
The service needs to boot another .exe so it is important having an absolute path to the bundled application. I solved this by writing the path to registry when installing, and reading when starting the service. I do this using the winreg lib. It works great in debug mode, but it seems the service is run under another user when starting the service normally, and it fails to load somehow.
I get Error 1053 : The service did not respond to the start or control request in a timely fashion when running. Importing the winreg lib is fine, but when using it crashes with no error. I'm trying to catch the errors and print but I get nothing on command prompt or the Event Viewer.
Any help appreciated!!
I am not sure if this is a right place to ask this type of questions. I am a python beginner or programmer overall at this point. I am using Spyder to use python 3.6 (via Anaconda). I wrote a code that works fine when I run it in the current Ipython console. But I really need to run it in an external system terminal. In order to do so, I chose the following path: Run-> configuration per file -> execute in an external system terminal. That has been working fine. But now it refuses to work!
I validated that there is nothing wrong with my code by running something simple and saw that running via external system terminal does not work.
So far I deleted Anaconda and re-installed it. Could someone suggest what I should be looking for to diagnose the problem and fix it?
Thanks!
I had the same problem and noticed that unless the Working directory settings is set to "The directory of the file being executed", it won't work.
You can change it in "Run" > "Run configuration per file".
I've been trying to get the Flask CLI to debug from within PyCharm with no success. I've tried the recommended procedures listed here. However, this doesn't work under Windows since flask.exe is an executable and not a script. Renaming flask.exe to flask does not work either. This causes the following exception:
Jetbrains has an active incident report in YouTrack for this, but there's been no activity done on it yet, with the Kanban State set to "Not On Board", so it looks like it's going to be sometime before the issue is addressed.
Any help would be greatly appreciated.
EDIT: Using Pycharm run works properly. Trying to run using the Pycharm debugger causes the exception
EDIT 2: Results after creating flask_debug.py file as recommended:
Firstly, rename flask.py back to flask.exe.
In PyCharm's Run Configuration dialog manually enter the full path to the Flask executable in the Script: text box. Don't use the browse button as it filters on Python scripts (.py files).
See screenshot. In this instance there is a virtual environment called "href" and the flask executable is in the Scripts sub-directory.
To use PyCharms's debugger create a file in the root say flask_debug.py:
from flask.cli import main
if __name__ == '__main__':
main(as_module=False)
Then setup PyCharm to run this script passing any Flask CLI parameters as required. See screenshot below showing Run/Debug configuration and the debugger stopped at a breakpoint.
Below shows Flask 0.12.2 quickstart app running under the PyCharm debugger and showing the defined environmental variable FLASK_APP.
In the latest version of PyCharm, there's an option to run by Module name instead of by file. Using "flask" as the module name works as well and doesn't require you to create a flask_debug.py file.
I'm attaching the screenshot of the working fileset and the Run/Debug Configuration for reference. This answer is thanks to the support provided by pjcunningham.