I can execute code in Command prompt using python. But recently I downloaded Atom and downloaded script but when I tried to run my code there it said: "python' is not recognized as an internal or external command, operable program or batch file." Please Help! Also, I used .py and .python to save the file but it doesn't work either way. I just wrote my first line of code yesterday. Print ('Hello World"). I have windows by the way.
Related
I am trying to run the flopy3_modflow_boundaries example from the FloPy Jupyter Notebook. The notebooks have worked perfectly well for earlier examples (including building, displaying images, running a MODFLOW-NWT model, and viewing the results...so I think have things substantially set up correctly), but for some reason when it gets to the following section of code:
!head -n 10 'data/test.riv'
I get the following error:
'head' is not recognized as an internal or external command,
operable program or batch file.
I'm not sure what the "!head" code with the exclamation mark is supposed to do, or how I can fix the error. If it matters, I'm running Python 3.9 on Windows 7. "Head" is a groundwater term, so I assume it is imported from FloPy in the first step of the notebook?
Thanks!
head is a Unix/Linux shell command to show the first n lines in a file. So running head -n 10 'data/test.riv' would output the first 10 lines in file data/test.riv. Note that when you precede a command with ! in a Jupyter cell, it runs the command as it would in a terminal, and not as Python code.
You can do any of the following:
Run the code on a Unix/Linux machine which has the head command.
Skip the command as it probably will not affect the rest of your code as it is meant to just show you the first 10 lines in the file, which you could just do by opening the file in a text editor.
Replace the command with an alternative command for head in Windows to perform the same function, although AFAIK, there isn't a direct equivalent.
I have some python script which is having more number of .py files, So I have generated .exe file for that, and I am trying to run using command prompt. I am unable to run .exe file in cmd prompt but when I tried to run on my friends laptop it is working fine.
I tried in cmd like below:
C:\pythonworkspace\Verification.exe -i C:\pythonworkspace\kpi_verification_2.0\config\Verification_config.xml
getting error as below:
Cannot open self C:\pythonworkspace\Verification.exe or archive
C:\pythonworkspace\Verification.pkg
Please help me where it is going wrong.
I'm pretty new to python and I am learning how to use basic command line operations with os.system() (os module)
I haven't been able to use TASKKILL recently and I need it for a python script I'm working on.
When I try to use TASKKILL in command prompt separately it doesn't work either. Only when I open the command prompt as administrator does it work.
The error I get:
'TASKKILL' is not recognized as an internal or external command,
operable program or batch file.
I'm currently using Windows 10 and Python 2.7.13, would appreciate anyone's help.
Thank you
I have a python (3.6) script prints the output using print() command:
print(convert_size(logsize))
Then I converted the script to .exe using cx_Freeze 5.0.1. When it does work from IDLE and prints the output, launching .exe file with double-click, or as Administrator, or executing it from cmd as Administrator doesn't produce any output at all: http://prnt.sc/emz5m4
I have tried to add input() at the end of the script and then re-compile the file to .exe, which supposed to "stop" window from closing but it still closes.
Does this happen to you only when compiling this script, or also with other scripts?
If you can't manage to get outputs into a console with cx_Freeze, maybe you can try compiling with pyinstaller. Specifically, the options '--console' or '--noconsole' will give you control over whether a console opens or not to see the outputs. It has worked fine for me.
https://pythonhosted.org/PyInstaller/usage.html
It appears the pyinstaller has been launched from 3.6 location since I had it installed for 2.7 and 3.6. Once the correct location (C:\Python27\Scripts) has been pointed to, the script has been compiled successfully!
I am trying to execute/call a python script that resides in another directory.
My Problem: When I attempt to open/call the file I get the error
'..' is not recognised as an internal or external command, operable
program or batch file
My python code to execute the python file is:
os.system("../test.py abc")
I have also tried this but I get the same error on a DIFFERENT part of the string:
os.system(os.getcwd()+"/../test.py abc")
# results in "c:/users/jim/work products/python/testdir/../test.py abc"
Error:
'c:/users/jim/work ' is not recognised as an internal or external command, operable
program or batch file
In windows you should use '..\\executeablename' to run a program or script in the parent directory, not '../' the unix style.
And, to ensure the script can run property, a 'python' is better to be added before the command.
So I think this situation should be:
os.system("python ..\\test.py abc")
It has not been tested since I am using linux, you can just try.
BTW, 'os.system' is kinda deprecated and the subprocess module is recommend to use when execute system level command.
A .py file isn't an executable, so that won't work on Windows. You have to run it with python.exe:
import subprocess
import sys
subprocess.call([sys.executable, '../test.py', 'abc'])
You could do this with system, but I figure this is easier because you don't have to quote the filename.