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.
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 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.
I am trying to run a python3 file out of the directory the file is located in on macOS catalina.
so I type the following:
python3 <file_name>
and nothing happens in my terminal, it just starts a new line in the same directory, but no file runs.
Up until now I have only ever used a jupyter notebook to run python, but now I am trying to run VS code and run the file inside of the terminal.
Anyone know how to fix?
I just wanted to say I fixed the problem trying a number of different solutions:
I downloaded the most recent version of python, ran certificates and update commands.
I selected the new python interpreter from VS code using shift+cmd+P and select interpreter option.
I ran the file in python launcher and then again in terminal and it works fine now. Thanks for participating in helping me solve this issue.
Alternatively if anyone else has similar problems, try the steps I mentioned, or maybe try setting up a pyenv to run python files in a virtual python environment.
I have installed Python 3.8.2 in my Windows 10 laptop
When I run the command 'python' in the command prompt, it gives me a blank response and goes back to the command prompt.
However when I run the command 'py -3' in the command prompt, python is launched.
What can be the reason for this. Is there anyway I can launch python using the 'python' command in cmd?
why does it need to be python? py is basically the same thing. Looks like you didn't check ambient variable in python installation. Just add python folder in PATH ambient variable and you're ready to go
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.