0

I have a python script that establishes connection to postgres db and writes results in csv.

When I run it from terminal on Mac, using command

administrators-MacBook-Pro:ml bob$ ./btltest.py -d dev -u temp_viewer -p "xxxxxxx" -l debug -s "2019-08-10" -e "2019-08-20"

it shows error

-bash: ./btltest.py: /usr/bin/python3: bad interpreter: No such file or directory

Using same credentials i.s. pass, user, db name as in the code to connect through pgadmin4 has no problem.

How can I remove this error ?

XCeptable
  • 1,247
  • 6
  • 25
  • 49
  • Your program can't find the Python interpreter. There could be a broken symbolic link. Run the command `which python3` or `which python` to show the path to the python3 executable. Are you in a virtual environment? – Julia K Sep 27 '19 at 23:25
  • no, local machine. the command outputs '/usr/local/bin/python3 ' – XCeptable Sep 27 '19 at 23:27
  • I see. This means that your python exe is under local path and the program looks for is under global /user/bin/python3. You have to create a symbolic link – Julia K Sep 27 '19 at 23:31
  • @JuliaK: this command take to bin – XCeptable Sep 27 '19 at 23:31
  • @JuliaK: can you please help how ? – XCeptable Sep 27 '19 at 23:32
  • Try setting the link: `ln -s /usr/bin/python3 /usr/local/bin/python3` – Julia K Sep 27 '19 at 23:36
  • ln: /usr/local/bin/python3: File exists – XCeptable Sep 27 '19 at 23:39
  • maybe this helps: https://stackoverflow.com/questions/31768128/pip-installation-usr-local-opt-python-bin-python2-7-bad-interpreter-no-such-f – Julia K Sep 27 '19 at 23:45
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/200082/discussion-between-julia-k-and-xceptable). – Julia K Sep 28 '19 at 00:25
  • Try `sudo ln -s /usr/local/bin/python3 /usr/bin/python3`, – tomalbrc Sep 28 '19 at 01:52
  • @defense2000x: administrators-MacBook-Pro:~ bob$ sudo ln -s /usr/local/bin/python3 /usr/bin/python3 ln: /usr/bin/python3: Operation not permitted – XCeptable Sep 28 '19 at 07:21
  • 1
    Ah, that's Apple's System Integrity Protection chiming in... I have it disabled on my machine.... I guess it would be easier to just change the first line in your `btltest.py`script to something like `#!/usr/bin/env python3` (*if* your script starts with `#!/usr/bin/python3`) – tomalbrc Sep 28 '19 at 07:35

0 Answers0