I have a really strange Problem with Python when used from the command prompt under Windows 10.
When I put "python --version" in the command prompt, nothing happens, this also means no error is thrown.
I cannot run any python script from the console, altough the path variables are set properly and I re-installed python 3.6 several times. It seems also to cause this error when no Python is installed on the system at all. Anyone an idea, what could cause such a strange behaviour?
CMD
Edit: I tried now "where python", which gives me two path:
C:\Users\set>where python
C:\Users\set\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Python36\python.exe
I removed the first path, which caused the error. It pointed somehow to an empty .exe
You can give a try python3 --version
Related
I am new to doppler. When I run the following command doppler run -- python3 I get an error saying Doppler Error: exec: "python3": executable file not found in %PATH%. I am following this tutorial to save configuration data on doppler: https://dev.to/lordghostx/build-and-deploy-a-web-app-with-python-flask-and-doppler-9jm#:~:text=The%20answer%20is%20YES%2C%20and,and%20environment%20variables%20using%20Doppler.
I can't get through step 6. Any help would be appreciated!
First thing you'll want to test is if python is actually on your path. For this, go to any blank terminal and just type "python3" and "python". If you don't get an output for either, or an error saying python couldn't be found, then you have to add python to your system path. See https://www.educative.io/edpresso/how-to-add-python-to-path-variable-in-windows
If you don't get an output for python3, but do get one for python, try replacing doppler run -- python3 with doppler run -- python and see if it works. Good luck!
Edit: "py" seems to work for you.
I have a CodeDeploy which deploys application on Windows instances. I have a Python script which is running as part of ValidateService hooks. Below is the code I have in that script:
print("hello")
So, I have removed everything and just printing hello as part of this script. When this script is called by CodeDeploy I get below error:
My appspec.yml file:
...
ValidateService:
- location: scripts/verify_deployment.py
timeout: 900
I tried getting some help on Google but got nothing. Can someone please help me here.
Thanks
As Marcin already answered in a comment, I don't think you can simply run python scripts in CodeDeploy. At least not natively.
The error you see means that Windows does not know how to execute the script you have provided. AFAIK Windows can't run python natively (like most linux distros can).
I am not very accustomed to CodeDeploy, but given the example at https://github.com/aws-samples/aws-codedeploy-samples/tree/master/applications/SampleApp_Windows, I think you have to install python first.
After so much of investigations, I found my answer. The issue is little misleading, there is nothing to do with Code format or ENOEXEC. The issue was due to Python path. While executing my script, CodeDeploy was unable to find Python (Though I had already added python.exe in Environment variable path).
Also, I found that CodeDeploy is unable to execute .py file due to Python path issue. So, I created a PowerShell script and invoking Python script from there. Like below:
C:\Users\<username>\AppData\Local\Programs\Python\Python37-32\python.exe C:\Users\<username>\Documents\verify_deployment.py
It executed Python script successfully and gave me below output:
hello
Today just for practice I have downloaded and installed vscode.
I saw a tutorial on the installation of vscode for python and followed the procedure exactly.
But upon completion, whenever any python code is running, it is throwing an exception.
Eg:- A simple code I was trying to run like
def greet():
print 'Hello world'
But the terminal is throwing an exception saying "Invalid Syntax"
I really don't know where I am going wrong
If anyone of you has experience working on vscode and is willing to help then please tell me what I can do
The extensions I have enabled:-
Code Runner,
Python
Earlier the python extension was not enabled, but even after enabling it, the error is still there
Please have a look at the problem I am facing in setting things up with vscode
You should not type in python in the terminal.
Because the Python Extension only sends some commands to the terminal and then executes them.
If you type python in the terminal you will enter into the interactive mode, and the commands which intended to be executed in the terminal will be executed in the python interactive mode, and lead to SyntaxError.
So, you can get out of the python interactive mode through Ctrl+Z shortcut or kill the terminal and then execute the commands in a new terminal.
I've written a script to rename my photos according to the date they were recorded. It runs on mac and uses the CLI exiftool by phil harvey.
The command that create problem is the following:
os.popen("exiftool " + file path)
I wrote the script using Pycharm CE. I used the exiftool because it yielded the best results and was the easiest to use at the time. With the command mentioned above, I got all the metadata nicely formatted by the exiftool and it only needed to be separated and put in a list. I tried everything in the console of Pycharm CE before I wrote the script.
The script and the console of Pycharm both worked fine. However, I tried recently to run the script with the IDLE from python. The script failed because the return from the console was always an empty string. Upon further research I used the subprocess.run()method. The error was
CompletedProcess(args='exiftool PATH', returncode=127, stdout=b'', stderr=b'/bin/sh: exiftool: command not found\n')
The output was also empty.
My questions are now:
Why does the Console and the interpreter of Pycharm CE find the exiftool but the console and the IDLE of python don't?
Is there a way to include the installation location of the exiftool so it is found by the os.popen() / subprocess.run() methods in the IDLE and the console?
Many thanks for your help
AliSot2000
At your command prompt, type which exiftool to find the full path to the executable. Then, instead of just calling exiftool in your Python script, use the full path.
Turns out, using which exiftool was indeed the solution.
I deinstalled python, reinstalled the newer version and tried the fix, proposed in the comment. (Using said command in Terminal and calling the command with the full path) It worked in the IDLE once I installed Python 3.7. I ran previously Python 2.7 on my MacBook.
I still don't understand why 2.7 wouldn't work.
Anyway thanks for the tip.
I normally program in Java, but started learning Python for a course I'm taking.
I couldn't really start the first exercise because the command
python count_freqs.py gene.train > gene.counts
didn't work, I keep getting "incorrect syntax" messages. I tried solving this looking at dozens of forums but nothing works, and I'm going crazy.
import count_freqs
ran without errors, but I can't do anything with it. When I try running something involving the file gene.train I get "gene is not defined".
Can anyone tell me what I'm doing wrong? Thanks.
type which python at the command prompt to see if the python executable is in your path. If not it either isn't installed or you need to amend your path to include it.
on Windows you can type echo %%PATH%% at the command prompt. It will give you at list of all the directories the shell search for programs to run. By default Python 3.3 will be installed on C:\Python33.