18

I'm using cygwin installed on Windows 10 and trying to access awscli from it.

I used pip install awscli to install awscli. This installed awscli. I then tried to run only aws to see if it is installed and I get the following error:

-bash: /cygdrive/c/Program Files/Anaconda2/Scripts/aws: C:\Program: bad interpreter: No such file or directory

I'm not sure why this is happening. Any help in this regard would be highly apreciated.

Patthebug
  • 4,647
  • 11
  • 50
  • 91
  • What does your `aws --version` output show? – Inian Oct 24 '16 at 06:13
  • Maybe this could help you; http://stackoverflow.com/questions/11319260/bad-interpreter-no-such-file-or-directory – Mustafa DOGRU Oct 24 '16 at 07:33
  • @Inian: Here's the output: `$ aws --version -bash: /cygdrive/c/Program Files/Anaconda2/Scripts/aws: C:\Program: bad interpreter: No such file or directory ` – Patthebug Oct 24 '16 at 15:26
  • @MustafaDOGRU - Thanks for the link. I tried to change the first line in the 'aws' file and included double quotes, but I'm still receiving the same error. Any other pointers would be helpful, Thanks. – Patthebug Oct 24 '16 at 15:38
  • 1
    Do you have python installed in cygwin? – Jordon Phillips Oct 27 '16 at 16:39
  • As Jordon Philips says, you need to ensure python - version 2.7.x is installed in Cygwin. Guide here: http://thecoatlessprofessor.com/programming/installing-amazon-web-services-command-line-interface-aws-cli-for-windows-os-x-and-linux-2/ – Zlemini Oct 31 '16 at 15:52
  • Python is installed in Cygwin. – Patthebug Oct 31 '16 at 16:53
  • What do you get at command line if you type `which python`? – cchamberlain Nov 02 '16 at 15:39

4 Answers4

14

This is still an issue even with the latest version of AWS cli. So after some trial and error I found a pretty good workaround that will not make you switch your favorite shell.

First, make sure python is on your PATH. That is from anywhere in the system you can just run python and it work.

Find the aws script and open it for editing (for me it was located in c:\Program Files\Python36\Scripts\aws) and change the hashbang (that would be the first line in the script) to #!python.exe. For me it was set to #!c:\Program Files\Python36\python.exe. That space in the middle of Program Files caused the issue when that path got converted to Linux like path. Changing it to #!python.exe sidesteps the issue.

When you update AWS cli, repeat the workaround.

PS. You could also avoid this issue by installing python somewhere in a folder without spaces in path. That requires to reconfigure your system, so I did not do that myself.

Mike Starov
  • 7,000
  • 7
  • 36
  • 37
  • Windows being Window... Thanks for the tip, it worked! Just got to make sure the right Python is in the path before any other. – rgoliveira Jun 14 '19 at 19:31
2

I would install the standard python and ensure it is coming up first in your path with which python and which pip. Path issues like this are due to mixing and matching executables targeting different platforms in my experience. Certain commands do not implement functionality to convert paths from Windows to Linux and back (it appears your specific commands are failing on spaces).

Since you say you are on Windows 10, if you have the anniversary edition, I would recommend Windows Subsystem for Linux over cygwin. You will likely see less Windows issues on WSL since it uses the exact same ubuntu packages you would use on Linux instead of the cygwin port and maps them low level to the NT Kernel.

cchamberlain
  • 17,444
  • 7
  • 59
  • 72
2

The Problem comes from "Program Files" having a space. This is something that is related to cygwin (I encountered the same error with git bash on windows). In a script I had something like this:

#!/c/Program Files/some_program/executable.exe

Escaping the space with a backslash or using quotes didn't work.

The solution is to use the DOS' short filename:

  • Progra~1 for "Program Files"
  • Progra~2 for "Program Files (x86)"

So my line would turn into:

#!/c/Progra~1/some_program/executable.exe
Younes El Ouarti
  • 2,200
  • 2
  • 20
  • 31
-1

In Windows:

cd .. to go to home directory which shows pwd as /. Now, cd to /cygdrive/c/Program\ Files/Anaconda2/Scripts

Now, run: python aws configure

Example:

user@user /cygdrive/c/Program Files/Anaconda2/Scripts 
$python aws configure
tuomastik
  • 4,559
  • 5
  • 36
  • 48
Venkataramana
  • 103
  • 2
  • 9