3

I'm trying to run my Python scripts via Cygwin from Windows. I'm getting the following error when running Python. The problem is when running Python via Cygwin it then runs the command via the Windows instance of Python i.e. C:\Python32\python.exe which then can't find the py file I'm linking to using the Cygwin way.

$ /cygdrive/c/Python32/python /cygdrive/c/elf/GIT/src/sfgenctl.py
C:\Python32\python.exe: can't open file '/cygdrive/c/elf/GIT/src/sfgenctl.py':
[Errno 2] No such file or directory

Is there a way around this?

Thanks

mlevit
  • 2,676
  • 10
  • 42
  • 50

3 Answers3

3

Use cygpath to convert it to Windows paths before passing it to python.exe:

/cygdrive/c/Python32/python "`cygpath -w /cygdrive/c/elf/GIT/src/sfgenctl.py`"
icktoofay
  • 126,289
  • 21
  • 250
  • 231
  • or you could just use windows path to start with ... cygwin understands it ... just doesnt like it much – Joran Beasley Aug 30 '12 at 03:19
  • @Joran: I was assuming that the path was being dynamically generated by some other program. If it really is just a constant, then sure, change it yourself. – icktoofay Aug 30 '12 at 03:23
1

I solve it by:

  1. Go into the folder where the script is. cd /cygdrive/c/elf/GIT/src/
  2. run python -i sfgenctl.py

Notice the -i flag.

Aminah Nuraini
  • 18,120
  • 8
  • 90
  • 108
0

Simple way of doing this was to install the Python Cygwin add on. Thanks for the helo guys.

mlevit
  • 2,676
  • 10
  • 42
  • 50