Running Python in Atom Windows 10 - python

I've installed Python 3.5 on my computer along with Atom. I selected Python in the bottom right and quickly wrote print ("Hello World"). However, I get an error message that says 'python' is not recognized as an internal or external command,
operable program or batch file.
[Finished in 0.364s]
I have looked up solutions online. I have edited the init file in atom as well as the environment variable path, with the path to python. Lastly, I have edited the "Command" field in the "Script" package to include Python3.
The code I placed on the init file is process.env.path = ["C:\Python27\ArcGIS10.2",process.env.PATH].join(";")
Links to where I found my solutions:
https://discuss.atom.io/t/cannot-get-python-to-run-from-atom-on-windows/15585/11
http://www.siliconcreek.net/computers/running-python-in-atom-io-in-windows
quora. com/How-can-I-run-Python-in-Atom
I am using a new windows surface, and am setting up my development environment for the first time on this computer. Please help.

Related

python is not recognized as an internal or external command, operable program or batch file

I realize that a lot of people have had this question but I've tried their solutions and they haven't helped me. I watched this video here but his solutions is not helping me:
fix problem
I can get python to work on the python app and using it the path of the python interpreter is
import sys
print (sys.executable)
>>> C:\Users\Owners\Documents\Python
I then set the environment variable like so:
I've also tried attached 'python.exe' but that didn't work either. When I then write python in the terminal I get the error message in the terminal.
You should make a new environment variable in your system variables named PATH if it doesn't already exist then you need to add your python interpreter path to that variable.
Adding Python.exe file in Path won't work as it is just an executable file, also which version of Python have you installed because according to this python 3.9.0 and above won't run on Windows 7 or earlier.If this is not applicable in your case then click on New in your system variables menu and add PATH as name and locate the Python Application Path and Python Scripts Path in folders (i.e where you installed Python) and add it to the newly created PATH

Python script installation fails on windows

I'm trying to deploy a larger python project which includes a script on
windows. Installation works fine on UNIX, but on windows it seems
impossible to get the script running. I've created a minimal example on
GitHub to demonstrate
the problem.
When running pip install ., the script is installed to C:\Program Files\Python39\Scripts\hello-world. The directory is contained in the
PATH. My user has read & execute permissions. The hashbang of
hello-world is replaced with #!c:\program files\python39\python.exe,
which also seems correct. However, running hello-world in the console
yields the following error:
C:\Users\malte>hello-world
'hello-world' is not recognized as an internal or external command,
operable program or batch file.
I expected this to work. Why doesn't it? How can I fix this?
I've tried some things, and noticed another strange behavior in this
context. Running shutil.which('hello-world') returns None. If I
rename hello-world to hello-world.exe, then calling hello-world
results in a strange error, most likely because windows
now thinks the script is a binary. That's fine. Except that now
shutil.which('hello-world')
returns 'C:\\Program Files\\Python39\\Scripts\\hello-world.EXE'. Why?
Update
The master branch of the respository now contains a solution that works cross-platform, which I learned from here: https://matthew-brett.github.io/pydagogue/installing_scripts.html.
It's not exactly clear to me, but the following paragraph from the Python documentation seems to state that a script with a hashbang line must have an extension associated with the python launcher in order for windows to recognize it: https://docs.python.org/3/using/windows.html#from-a-script
In other words, it appears that my assumption that using the scripts parameter of setuptools.setup works cross-platform is subject to some conditions which are hidden somewhere in the python documentation.

Create python exe in windows with pyinstaller?

I'm trying to create an executable from a python script that I created, but I'm stuck
I installed Python 3.9 x64 for windows and pyinstaller, following different tutorials, but nothing works to me. The initial tutorial was this (I followed others similiars to this too):
https://datatofish.com/executable-pyinstaller/
next, when I was trying to create the .exe with the command: pyinstaller name_archive.py
I got the next error:
'pyinstaller' is not recognized as an internal or external command,
operable program or batch file.
for that problem, I found some solution here:
https://www.it-swarm-es.com/es/python/pyinstaller-no-se-reconoce-como-comando-interno-o-externo/834789072/
I added to the Environment Variables, to PATH, in User Variables and System Variable both, the next dir:
C:\Users\User\AppData\Roaming\Python\Python39\Scripts
Now, running again the command: pyinstaller name_archive.py in the cmd and with the route of the archive (C:\Users\User\Desktop\K1>pyinstaller name_arhive.py) gives this error:
Fatal error in launcher: Unable to create process using '"c:\program files\python39\python.exe" "C:\Users\User\AppData\Roaming\Python\Python39\Scripts\pyinstaller.exe" name_archive.py': The system can't find the specified file
I looked for the problem widely in the web, but I couldn't find any helpful information, even in the pyinstaller website... (https://pypi.org/project/pyinstaller/)
Please help, I tried anything for the last four hours and nothing results... lol

Python script won't run from the command line. It shows no error

I'm trying to run a simple Python Script on the CMD but nothing happens when I run it. I get no errors or anything. The py script is just a simple print ("Hello World").
All my .py files are in the Python/Projects file.
http://puu.sh/FFfJm/ee63955506.png
Just some context regarding this:
I did install Python then Pycharm then Anaconda. I don't know if that has anything to do with conflicting Python files.
python isn't in your path. Checkout Adding directory to PATH Environment Variable in Windows, which is a good reference to the question of adding a variable to the path in CMD.
Are you sure you entered your command line query correctly?
python python_file_name.py
If you just entered your file_name.py it might have executed it but ended it simultaneously before you could see any result.
also try putting your file_name in double quotes.
If you have Python in PATH but script execution still doesn't work, inspect the C:\Users<user>\AppData\Local\Microsoft\WindowsApps folder.
There might be a zero-size python.exe file. It seems that this folder is earlier in PATH and zero-byte file intercept the console command execution. The microsoft store is opened with python page if I run that file.
I removed this folder and python script start working again.
You also can ensure the correct python is available to the terminal with 'where python' to see the full path.
From your screenshot, you'd need to call
python "Hello World.py"
with quotes, not
python Hello World.py // no, won't work
The reason is, when you don't include quotes around a filename with a space, it only takes the FIRST thing you wrote as the script name, the rest of the "words" are just passed as "command line arguments"

"python.exe can't find '__main__' module in ..." Error when trying to run python script opencv_blink_detect.py in virtual environment,

Apologies if there's missing information. I'm using python for medical research and am trying to run a program to count the number of blinks via video footage.
https://github.com/skvrahul/blink_detect
The script is located here
My virtual environment is set up here:
Package install instructions were followed from here
Terminal open via Anaconda
Attempt to run via readme instructions
Attempt to direct terminal to look at file path
As you can see, the error message is
(opencv-env) C:\Users\wmj>python C:\Users\wmj\Documents\Python Scripts\Biometrics\blink_detect-master.py -p -sp.dat
C:\Users\wmj\AppData\Local\Continuum\anaconda3\envs\opencv-env\python.exe: can't find 'main' module in 'C:\Users\wmj\Documents\Python'
The contents of C:\Users\wmj\Documents\Python is just Anaconda3-2018.12-Windows-x86_64
I have searched online and most solutions to this problem seem to be either solved by modifying the .py file or doing something with Pycharm
What is the solution to this? I want to be able to run the script as a demonstration to my supervisor
Thank you,
WW
Try first to cd to the exact location of the package and then run exactly as written in the readme instructions.
Python has to get the full path of the script you're trying to execute and the script itself has to get the sp.dat file as an argument.

Categories