I'm trying to execute a python script from a cocoa app I created using XCode. The issue is that, the files are not getting written to the desired location. When I run the script through the terminal, its working fine. I tried running it as root as well. Still not working
Here's the error that's coming up:
convert: unable to open image ` /Users/anil/Desktop/mp_checkmarkgreen_md_d_lt.png': No such file or directory # error/blob.c/OpenBlob/2709.
convert: WriteBlob Failed ` /Users/anil/Desktop/mp_checkmarkgreen_md_d_lt.png' # error/png.c/MagickPNGErrorHandler/1805.
Is there anything else I should be doing while running the script?
The error is 'No such file or directory', is that an extra leading space I see before the first / ?
:-)
Related
Everyone. I met a issue says that "This app can't run on your PC" when I want to run the a .exe file using python script. The thing is I could run it in Command Prompt, it works well. but when I want to run it using python script in VS Code, it says
I tried many methods google from the Internet, it still doesn't work. Here is what I want to run in python
os.system(" cd C:\Program Files (x86)\Ixia\IxChariot ")
os.system(" runtst.exe -t20 C:\\Users\\Admin\\Documents\\IxChariot\\Tests\\mlo_delay.tst C:\\csv\\6G_d.tst ")
Does anyone have idea what is the issue and how to fix it? thx
First, please set permissions for your vscode. It seems that it runs files in the system disk. Then, you can use os.popen() to open files.
For example:
import os
google = "C:\Program Files\Google\Chrome\Application\chrome.exe"
os.popen(google)
my python files are running in the terminal, however when i actually run the .py file in file explorer they dont run, they only dont run after importing a non already installed python library, for example colorama.
Im really new to programming so any help appreciated.
My guess is that the python executable you associated with the .py filetype in your operating system is not executable you expect. This could happen, for instance, if you have both plain python and conda python on the same system.
The following is more of a suggestion than an answer, but it's too long to put in a comment:
First, try putting input('Press enter to continue...') at the end of your file, so the window won't close immediately on error.
Next, run the code import sys; print(sys.executable); print(sys.path); input('Press enter to continue...')
The output of the above code will tell you the exact location of your python executable as well as what folders your program draws your libraries from.
Please start VS Code in a project (workspace) folder.
I have a Python script with the following code:
#! /home/flohosting/PythonTest/PythonTest/bin/python
print()
print("hello world!")
I'm running Python 3.6 on a GoDaddy VPS. The Python 3.6 is a virtual environment. This script works just fine. The problem arises when in Virtual Studio Code I open a new document, copy the code above from the working .py script and then paste it into the new .py script, upload the script, CHMOD to 755, and try to execute. Then I get a 500 Internal Server Error. It makes no sense to me.
I've logged into my SSH with PuTTY and tried to CHMOD a+x file_name.py where "file_name" is the exact filename and it still doesn't work. I can't think of anything else to even check to see why the script works in a file that's been on the server for 2+ months and not in a new script I upload and CHMOD to 755. Thanks for any suggestions.
EDIT: the link to the script working is http://www.dockethound.com/bernard.py
The link to the non-working script is http://www.dockethound.com/hello.py
EDIT 2: I figured something out and it is working though I have no idea why.
When using CuteFTP 9, I upload on "AUTO". I decided to select ASCII and then try uploading again. When I uploaded I got an error that said "This appears to be a binary file you want to upload with ASCII. Are you sure?" So for some reason the file is being saved in a binary format or something that CuteFTP recognizes as a binary format and is uploading it in binary which causes Apache issues when trying to run it. BUT if it's uploaded in forced ASCII mode, the problems are solved.
Jarod
In my situation, using the Auto setting in CuteFTP 9 allowed CuteFTP to determine that the file types with .py were binary files so the files were transferred via binary and not ASCII. Forcing ASCII fixed the problem, then going into TOOLS->Global Options->ASCII types and adding PY to the list fixed the problem.
I want to run a Shell script using Automator in OSX. The shell script calls a Python file which is located in the folder "/Users/Tex/Python". My code is:
on run {input, parameters}
tell application "Terminal"
do shell script "/Users/Tex/anaconda3/bin/python /users/Tex/Python/MoveFiles.py $#"
end tell
return input
When I execute the automator script I get an error as follows:
Terminal got an error: /users/Tex/anaconda3/bin/python:
can't open file '/users/Tex//Python/Move_Files.py': [Errno 2] No such file or directory
I suspect that the problem is that the "/Users/Tex" folder is located on a different drive to the OSX operating system but that the Shell interpreter is not aware of this. I have tried using the full path to the python file, i.e. including the volume name (iMac Disk A) however the fact that this has spaces in it seems to create yet another issue for the Shell.
Appreciate feedback on how to make thsi work!
I have some images that load in my python script.
they reside in c:\Python27\subfolder\images\
in my .py file (which resides in c:\Python27\subfolder\ )
I load them with ./images/file.jpg
It works just fine in IDLE
However when I run the file through notepad++ I get the error:
Failed to load file ./images/file.jpg
How can I fix this with out having to change my actual python code? (It works if I load the images with the full path, but I dont want to do this).
Im using the run command C:\Python27\python.exe "$(FULL_CURRENT_PATH) in notepad++
thank you very much!!
Well to help you fix the problem, you should do this
import os
print os.getcwd() #gets the current working directory
Most likely your problem is that within the IDE, your CWD differs than when you're running it from the console.
If you want it to work like it does in the IDE, you should first get yourself (the console) within that directory, via navigation (os.chdir(...) command).
You could also make a batch/bash file that runs the python script from the directory you need, and call that file from wherever you want (it would still call the python script with the path you gave