I was working on a python project where I was about to run it, but then the command prompt responded with: "'python' is not a known bash or shell command."
I tried closing and opening the command prompt, but this time it worked. I don't really have a problem with it, but just wanted to know why this happened.
Related
I am trying to run the following simple python script called 'main.py', through a pipenv virtualenv:
print("started.")
Executing pipenv run ./main.py --verbose (in pipenv venv) does not print anything to the console.
Through VS code, running pipenv run ./main.py --verbose outputs the following:
That is to say, the python file seemingly does not run, expected 'started.' to be printed to the console, recieved nothing printed and program terminating.
This behaviour is also present when I attempt to run it through cmd, note the error produced with the --verbose flag:
I can run it sucessfully through just using python, however I really want to use pipenv to manage packages ect. I guess I'm mostly just curious at to:
Why does this error occur?
What does the following error, caused by running it with --verbose flag, mean?
[5772:0107/202720.999:ERROR:broker_win.cc(56)] Error reading broker pipe: The pipe has been ended. (0x6D)
How do I fix the issue?
I have reinstalled Pyhton, pipenv, and vscode - but have recieved the same results. Running the 'pipenv run' command both within the shell and outside the shell have the same results.
EDIT:
A Visual Studio Code issue
In the post above, after runing pipenv run main.py, vscode would always open. Whats stranger is, once vscode is uninstalled, the command works as expected! So an additional question of mine is,
Why does vscode make this issue happen/what's the fix for being able to code using vscode and running pipenv run?
see bellow for what occurs when running pipenv run main.py with vscode initally closed:
This screenshot is after ~5mins of no action in iether the vscode console or the cmd console. The program never exited, and closeing the cmd also closed vscode.
pipenv run main.py means open the file in the ide you chose in the pipenv environment.
In this way, it just opened the file instead of run python file.
You need to use command python main.py to run it.
I am trying to change the Executing Terminal for python in VSCode from Bash to CMD. I already tried changing the default terminal by following this, but no luck.
Detailed Explanation:
In Vscode , when i hit the run button for executing python. I see that , the execution automatically chooses the Bash terminal , but i would need the execution to happen in CMD.
You can check it in settings.
It's the same as adding the following line into your setting.json:
"terminal.integrated.defaultProfile.windows": "Command Prompt",
If it still doesn't work, try reinstalling vscode
If you just changed your default terminal, try restarting your computer, that worked for me, it wasn't taken into account before I did.
I have a Python file called log_reg that I'm just trying to run in the anaconda prompt. I use the following commands:
cd Desktop
cd ML_models
python log_reg.py
I hit enter, and I don't get and error, but I also don't get any result or the file I'm trying to run. What should I do?
You should try running your code from the command line and see if it works. Go to the command line and type python log_reg.py and see if it runs. If so you'll know your code is correct. Then you can try running it at the Anaconda prompt.
I installed python long back and worked fine for all these months, I could install libraries from command prompt..run python programs using shell from vba until one day..It started failing, I am able to run python scripts from idle but not from command prompt or vba. I have tried checking my permission but to no success.
If I type python on command prompt, it says the app can't run on this pc and later "Access Denied" displays on the prompt.
To someone who might find this: I had the same problem, when I checked the python.exe file located at C:\Users{your user}\AppData\Local\Programs\Python\Python37 it had 0 bytes, I just reinstalled it to solve the problem, I don't know how this happened.
Whenever I run python script on windows command prompt, the command prompt shuts down automatically.
Does anybody know the reason? How can continue working on windows command prompt even while my python script is running? Please help.