How to run an executable on Cygwin - python

Say I want to run an executable with a filename argument that is within my working directory, in Windows cmd I would go:
C:\Python27\python signalme.py
How can I do so in Cygwin? NOTE: C:\Python27\python is an executable. Please give me a full answer, I read somewhere here that you should add a .\a, but I couldn't know where to add it.

Cygwin attempts to make a Linux-like user environment available on Windows. To run a executable file on a Linux-like command line, you need the following things:
You have to be able to find the executable, which means one of the following:
The executable is in a directory that is included in your PATH environment variable.
You know the explicit absolute path to the executable, which you can specify at the command line
You know the relative path from the current directory to the executable, which you can specify at the command line.
The file has to have the executable permission set for the user you're attempting to use to run that file.
So, to run an executable in your working directory, you can specify the relative path to the working directory, along with the filename: ./foo.exe.
In your case, you want to use the Python interpreter to run a local Python file. You will most likely need to use the Cygwin-installed Python. That Python will probably be in your PATH, so just run:
python signalme.py
This could fail, with an error message like bash: python: command not found - in which case you should re-run your Cygwin setup, look for the opportunity to install Python, and make sure you install it.

/cygdrive/c/python27/python.exe signalme.py

Related

Run python module commands on Windows

I installed Sphinx using pip install sphinx command in Windows Terminal and I want to run sphinx-quickstart to make documentation in my docs directory but it doesn't work.
I get this error instead:
sphinx-quickstart : The term 'sphinx-quickstart' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
If I try to run it via GitBash or using py or python at the beginning that says:
\path_to_python\python.exe: can't open file '\My_working_directory\docs\sphinx-quickstart': [Errno 2] No such file or directory
How can I solve this problem?
The easiest way to do it is to create simple virtual environment and you will able to install packages you want and run it.
Just create folder and run command to create virtual environment then just activate it using .bat file.
Read the docs but it can differ in future versions of Python.

os.system does not look the programs that are in my path

I have a problem when calling programs inside a python script. The programs that are giving me problems are those that I have installed manually on my computer and then added them to path on .bashrc file. The programs that where installed using 'sudo apt-get install some_program' don't give me any problem
The programs where added to my .bashrc file as the following way:
#path to fastqc
export PATH=$PATH:/home/bioinfor3/bin/FastQC/
#path to fastx-toolkits
export PATH=$PATH:/home/bioinfor3/bin/fastx/
Inside my PyCharm, I am using the os module to call those programs the in the below manner:
os.system('fastqc seq.fastq')
And I get this error
sh: 1: fastqc: not found
I guess it has something to do with the sh path or something, but I am not able to make it work
EDIT:
If Pycharm is launched from the terminal, it inherits the bashrc file with my personal paths and it works
Presumably this is happening because you have modified your login environment to adjust your PATH, but this updated path isn't seen by the shell that's running PyCharm, or PyCharm appears to be nullifying it somehow.
You should first of all verify that
os.system('/home/bioinfor3/bin/FastQC/fastqc seq.fastq')
operates as you would expect (no reason why it shouldn't, but worth checking).
It seems from this answer that by default PyCharm doesn't use bash for its shell but tcsh. Therefore it isn't seeing the setting you are enforcing on bash.

Some commands not working in Command Prompt

I am using command prompt to run CUDA on windows. When i open cmd, the current directory is pointed towards home folder. When i type nvcc, output is nvcc : fatal error : No input files specified. It means i can run nvcc with a file. But, when i type python, it shows
'python' is not recognized as an internal or external command,
operable program or batch file.
I need to change my directory to run python.
My question is, how to make python run without changing the directory? Is it like inputting cmd about change in the library path as in ubuntu?
Windows, like Ubuntu, has the concept of a "path", which is a list of directories that the shell will search to try to find the command you typed. Therefore, the nvcc command is probably located in a directory found in your system's path, but the python command is not.
Therefore, you'll need to find where on your system the python command is, and put that command's directory into the path. So, if python is located at C:\Python26\python.exe, you will need to add C:\Python26 into the path.
Superuser has some answers that can describe how to modify the path in windows, or otherwise you can google how to do this. The exact steps may be different depending on the version of Windows that you have.
Additionally, you can also ignore the path and run the python command using the full filename. Instead of typing python, you would type (using the above example) C:\Python26\python. This would have the same effect, although would be a bit more typing.

Ruby system call not observing path for python scripts

This works:
system "python \"C:/Program Files (x86)/Google/google_appengine/someScript.py\"
This doesn't work:
system "python \"someScript.py\"
The directory containing someScript.py is added to my windows PATH variable, so if I open a CMD window and type:
someScript.py
it runs fine.
How do I make is so that my ruby script is able to call someScript.py while observing the windows environment path variable so I don't have to specify an absolute path for the python script?
Python does not use the $PATH environment variable.
You always have to specify a full path to the python script on the command line. This can be relative from the current directory or an absolute path.
The association between files with the .py extension and the Python executable is a separate registration, where Windows executes the Python executable after the script file has been located on the current search path. Windows passes the full, absolute path of the script to the Python executable when it invokes it. When you execute the Python executable directly using system you bypass that lookup.
You could try to execute the Python script directly using system "someScript.py" without the python executable, but I am not familiar enough with Ruby and Windows to know if that'll honour the .py extension registration used by the Windows command prompt.

Installing python 2.7.2 on Debian 5.0

I'm having some trouble running the ./make command in my debian command line to install python 2.7.2.
I untarred my download from Python.org and ran ./configure which appeared to have worked fine. Unfortunately when I type in ./make I get the following error:
./make: No such file or directory
Not sure why this occurs, but I'd like to get an updated version of python to continue learning the language.
Thanks for your help,
Andy
When you type ./configure, it runs a executable script in the current directory (labeled with a .) called configure.
Make is an executable file, usually located somewhere like /usr/bin, which uses a file in the directory to run a bunch of commands depending on whether files are up to date.
When you just type make, your shell (the program that handles all your commands and sends their output to the terminal) will go looking through all the directories in the PATH environment variable to find an executable file called make, and run the first one it finds. But, when you type ./make, you're actually telling it to try and run an executable file in the current directory, called make. (It uses this approach, not searching the PATH variable, whenever you put a / in the command.)
You can use the . anywhere you could use a normal directory to specify the same directory, so for example: /usr/bin/././././ is the same as: /usr/bin. Similarly, you can use .. to specify the directory above, so /usr/bin/../bin/../bin/../lib is the same as /usr/lib.
So, after running the configure script located in ./, which generates a so-called makefile, you run the system wide version of make, located where ever, by just typing make, which uses the makefile to build the package.
Also, you can use the which command to find out where the command that'll run when you enter a command by itself - for example, which make.
(Apologies if any of this is condescending, I was going for completism. Also, I may have overused the code tags...)
its not ./make
try
"make"
as it is

Categories