Python files' outputs are ************ regardless of python files that I execute - python-3.x

Thank you in advance for answering my question.
I tried to execute my python files on Windows command prompt. However, '************' is the only output I can get regardless of the files I execute.
For example, test. py consists of only one-line code which is
'print("Python check")'
troubleshooting_1.py is just the same code as test.py. It consists of
'print("troubleshooting")
I don't know why this problem occurs.
Below is the result of where python
> C:\Users\User\Desktop\sshackathon_project_2>where python
C:\Users\User\Desktop\sshackathon_project_2\python
C:\Users\User\Desktop\sshackathon_project_2\python.py
C:\Program Files\Python37\python.exe
Windows command prompt

Related

Execute python executable and script inlucing full path

Im trying to create a python script with executes a series of python and sql scripts.
Some need to be executed using one python executable and some using another.
I've tried
from subprocess import call
call([r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
And
call([r"cd C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3", "pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
But the script isnt being executed.
I think the problem might be "How to execute an .exe file in windows terminal including full path to it"?
Please check my code. It is working well in my side.
from subprocess import call
call([r"C:\Python38\python.exe", r"E:\python\hello.py"])
As i think, the problem is that you use pythonw.exe.
if you use pythonw.exe, you can see any log in terminal.
Pythonw is useful for running script with GUI.

Trying to test Python on Win 10, getting Errno 2. Path to python is given to the value of env variable

I've installed Python 3.8 on Win 10 machine. Path to Python is C:\Users\userid\AppData\Local\Programs\Python\Python38\
Path environment variable values are: C:\Users\userid\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\userid\AppData\Local\Programs\Python\Python38\python.exe
In order to test python, I created a simple script called "script.py" in directory C:\python_scripts.
Then I tried to run "script.py" from the directory where it is located, but got error:
C:\python_scripts> python script.py
C:\Users\userid\AppData\Local\Programs\Python\Python38\python.exe: can't open file 'script.py': [Errno 2] No such file or directory
What might be the cause of getting this error? i tried to run the script with both cmd and powershell, with the usual user rights and with elevated admin rights, still getting Errno 2.
No other versions of Python have been previously installed on this machine (which is a corporate one, if that might be significant)
Thank you
Thank you #OferSadan for your suggestion to use dir command, it helped me to solve the problem. The "script.py" had an additional .txt extension added to it for some reason, but the Windows explorer only showed .py extension by default. Now I deleted the trailing .txt suffix and the script runs

SyntaxError: Non-UTF-8 code starting with '\x90' in file .\score_python.exe on line 1, but no encoding declared;

I have a python script where I need to create an executable via pyinstaller. Successfully created the exe, but shows the above error while running.
I have already searched on the web and tried many solutions but none of them is working. tried with # -*- coding:utf-8 -*- in the first line of the script but fails.
using Python3.7, PyInstaller3.5
Can anyone help me with this?
Ensure you are not calling the executable using python again.
As in
python long-path-to-the-converted-scrip\script.exe
It is a common mistake, due to the fact that you used python to run the script before, then you try to recycle the same command but forget to delete the python call. The long path to the script (now converted to exe) obfuscates the fact that python is no longer needed at the beginning...hence your error.
Resolution: Please execute the exe without python command.
Example: If you have converted test.py, please go to the directory Current Directory/dist/test/ and either double-click on test.exe or run test.exe from command line.

I can't open a python file in git bash

I'm trying to open a .py file on git bash but it doesn't work.
I have tried to follow some instructions like running python <filename> but it doesn't work for me.
When I run
python python_basics
I expect it will open the .py file but it says it can't open file 'python_basics':
[Errno 2] No such file or directory
From this question, the problem may very well be caused by Git Bash itself.
I would recommend you try running your Python file from a different terminal (Command Prompt or PowerShell if you are using Windows), using the command suggested in the comments:
python python_basics.py
Thank you for your question, I am here to help you and who will see this question.
if you mean you want to open the file like when click on the file and open it
you can use this command
Start filename.py
but if you want to open the file inside the gitbash use this command
vim filename.py
and if you mean to run the file from gitbash you can use this command
python pythonFileName.py
Now if the above command did not work with you, and you are in the windows10 Pro platform you should go to
environment variable >> Then system variable >> then choose path >> then Edit >> and put the python path >> restart the terminal and run it again
Notice: All of the above I tried and used in windows10 pro.
Thanks,
Hope to help anyone,
First check the python version installed on your system.
by command-
python --version.
If not found
set
$ PATH=$PATH:/c/Python27/
Adapting the path will solve your problem.

How to run python by Notepad++

I want to script with python using Notepad ++ but it works strangely, actually it does not work, so I have pycharm an everything is going well but in notepad ++ when I save file with .py and click run it does not work is there a step by step instruction to follow?
I have same problem with sublime text editor so I am lucky with just Pycharm all of the others has confused me please help me.
Notepad++ and sublime are text-editors and not interpreters. To run python script, you need a python interpreter. If you want to use notepad++, then write the python script in notepad++, open command prompt and run the python script from command prompt.
Assuming that you have python installrd, suppose you have created a file name "example.py" in the path "C:/Users/User/Desktop", then to run the script you will have to run the following commands:
$ cd "C:/Users/User/Desktop"
$ python example.py
I have no idea Why you gave me this -1 may be someone think that he knows everything so my idle.py is not the same location to my computer and when I assign location it pops up an error
sorry for error message image it is unable to copy

Resources