0

I have a problem that started by trying to execute

some_aws_command = 'aws s3 <do some stuff>' # the real command has been purposefully obfuscated but that doesn't matter here
subprocess.Popen(some_aws_command.split()).wait()

Which resulted in a weird error:

FileNotFoundError: [Errno 2] No such file or directory: 'aws'

After some digging, I found that through the execution environment (I'm using PyCharm's run functionality) there's no longer access to the aws cli executable.

The following code behaves differently from the terminal than from PyCharm's Run:

import shutil
shutil.which('aws')

Via the terminal it returns the expected path - '/usr/local/bin/aws', but via PyCharm's Run, it just returns None. This was working previously, and I can't figure out what change caused the break.

Any ideas on how to get it to work again?

Joey Baruch
  • 4,180
  • 6
  • 34
  • 48
  • Maybe you should add more details. Are you trying to create a Run Configuration? Are you trying to run these commands in PyCharms terminal? Are you trying to run those commands in a script? PyCharm is a big IDE with a million different features. Please help us understand what you are actually trying to do, so that we have some kind of context. – Jens Aug 06 '21 at 22:58
  • 1
    why not use `/usr/local/bin/aws s3 ` – furas Aug 06 '21 at 23:10
  • you should check `echo $PATH` to see if you have `/usr/local/bin` in `PATH`. Maybe PyCharm has some option to set custom `PATH` or use `PATH` from system - and this can make problem. – furas Aug 06 '21 at 23:13
  • You need to activate the venv that has aws installed. – bad_coder Aug 07 '21 at 02:48

0 Answers0