If I use
import os
os.system("pdflatex myfile.tex")
from iron python it just works. If I start to Automator and use "Run shell script" switch the shell to python the same command is not executed anymore. Any ideas ?
Related
I'm trying to create an Automator application on Mac OS X Mojave which starts my pyenv.
If I run this command from the bash shell it works fine:
pyenv activate myenv
However from within Automator I get the following error:
The action “Run Shell Script” encountered an error: “[31;1m
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
[0m”
[31;1m
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
[0m
If I add whoami at the start of the shell script, then it shows that Automator is running the script as me, so it should have the same $PATH etc. However if I echo the $PATH variable it is clearly not the same as when I run it directly from the shell. Manually setting the $PATH in the script doesn't help either.
Oddly, running python --version in the script does not generate any output.
Running which python does generate output: /usr/bin/python
Any clues as to why this doesn't work?
I am trying to automate a python script with a keyboard shortcut. To do this, I am using the mac automator. In this, it runs this applescript:
on run {input, parameters}
do shell script "python /Users/evettsam000/Desktop/myKeys.py"
return input
end run
When I run it, it makes it to the python file, which starts by importing time, and then importing pyautogui. But there's an error when I run it from the automator, saying there's no module called pyautogui. However, when I run the python script by itself, it works. Is there any applescript command I can use to help this import? Thanks!
Pretty much as titled. If I were to manually do this, I would first open a Cygwin Terminal (which should be /cygwin/bin/mintty.exe), and then in that terminal, cd to the directory that has the python script, and then execute the python script by doing "python myPython.py". I'm wondering if I can write a batch script or a bash script to do this: start a Cygwin Terminal, cd to a directory, execute a python script in the directory.
Thanks.
Edited:
So I have a python script that generates csv files for activities through mongodb.This script won't function if I run it through windows cmd. I have to run it in cygwin terminal (mintty.exe). So any alternatives to execute the python script won't work. I have to somehow start a Cygwin Terminal and execute the python script through there. Any ideas please? Thanks.
Depending of your needs it could be better to start mintty (creating a new window) instead of starting bash inside the cmd.exe window.
When you want to use ansi escape sequences then it works better with a real mintty window, as the cmd window ignores the escape sequences for window resizing and positioning.
start "" C:\cygwin\bin\mintty --exec ./myProgramToExecute.sh
You may start a bash from the Windows terminal and start your script from there (without starting mintty.exe). Just execute
bash -c "cd /your/directory && python myPython.py"
from the Windows cmd prompt or a batch file.
I know there is a Terminal plugin for quicksilver but I would invoke terminal commands which basically just runs in the background and never popups a terminal window. is that possible?
UPDATE:
I have the following code in my applescript but its giving me an error:
do shell script "/path/to/shell.sh blah"
error:
curses.setupterm()
_curses.error: setupterm: could not find terminfo database
In Quicksilver you can use the action "Run Command in Shell", which is part of the "Terminal Module". The command is run without showing a window. Search on the quoted terms and you'll find some examples.
Applescript is the simple solution, see:
http://developer.apple.com/library/mac/#technotes/tn2002/tn2065.html
Sample:
do shell script "ifconfig"
do shell script "ifconfig" user name "Anne" password "p#ssw0rd" with administrator privileges
Automator can also run shell scripts in the background.
If you are familiar with XCode, you can use NSTask with Objective-C.
Hold on a sec, is your shell script a bash shell script? In your first line do you have:
#!/bin/bash
If not, add that line to your script.
Also instead of just
do shell script "/path/to/yourscript.sh"
consider this:
do shell script "/bin/bash /path/to/yourscript.sh"
I am attempting to get python to run in a command shell in emacs. I have tried the standard M-x shell that comes with windows emacs and then type 'python' but python just hangs up (no output). I have also tried running other program shells such as bash.exe from cygwin with the same result. Any way to get a shell that can run other programs like python?
Why not use M-x python-shell? This provides an interactive REPL for Python within Emacs.