I am truly stumped.

This command works perfectly fine if I enter it at a terminal prompt in Ubuntu 20.04:

python3 -c 'import hddcoin.util.bech32m as b; print(b.decode_puzzle_hash("awalletaddress"). hex())'

But if I do the same command in a bash script:

PUZZLEHASH=$(python3 -c 'import hddcoin.util.bech32m as b; print(b.decode_puzzle_hash("awalletaddress"). hex())')

I get "command not found". If I change the "python3" to "venv/bin/python3", which is what I get when I do which python3, then the error becomes "no such file or directory". Which makes me think that now it's not finding the python script I'm trying to find with the import hddcoin.util.bech32m part. But in the bash script I am CD'd into the parent directory of that python script.

I can actually cut and paste the command as displayed in the error message into a terminal prompt and it runs fine.

I've searched everywhere and cannot find anyone asking a similar question. All searches for "no such file or directory" are failing when entered into a terminal prompt. No one has had an issue with working fine in terminal but not in a bash script that I can find.

Tried shebangs #!/bin/bash and #!/usr/bin/env bash, neither work. (Corrected)

  • I'm pretty certain the command that was not found was python3 itself, because adding venv/bin in front of it gets rid of that error and it then becomes " no such file or directory". I think that looks like a bash error too, but the error message offers no additional information about what its referring to. And you're right about shebangs, I just typed em wrong. BTW I did try adding every possible relevant parent directory to the PATH within the script. No good. But can't see how it could help since the PATH doesn't have those directories at the terminal prompt and yet that works fine.
    – Qwinn
    Sep 1, 2021 at 8:11
  • You need to go step-by-step. Where did you type which python3? In a terminal or in your script? If you're able to find python3, then try an easier line to test -- maybe without the import. A simple "Hello, world!", for example. The top of your bash script should definitely have a #!/bin/bash as the first line. Note the #!/ as the first 3 characters...
    – Ray
    Sep 1, 2021 at 8:51
  • @JacobVlijm Point taken but it was also in response to the last sentence that says "Tried shebangs #!bin/bash and !usr/bin/env bash, neither work.". Both of these paths are wrong...
    – Ray
    Sep 1, 2021 at 9:13
  • 1
    @JacobVlijm Ah! I see... Probably better for Qwinn to just go correct the original question? There's too much information missing from the original question and a long set of comments will turn people off...
    – Ray
    Sep 1, 2021 at 9:27
  • Feel free to post your own finding as an answer here, and accept your own answer.
    – vanadium
    Sep 1, 2021 at 14:21

1 Answer 1



Thanks for the help everyone, I figured out what was going on. For posterity I'll explain.

My actual original attempt was this:

PUZZLEHASH=$("python3 -c 'import $FORKNAME.util.bech32m as b; print(b.decode_puzzle_hash(\""$WALLETADDRESS:\"). hex())'")

This seemed to expand properly, with the following error message:

/home/qwinn/forktools/forkexplore: line 86: python3 -c 'import hddcoin.util.bech32m as b; print(b.decode_puzzle_hash("awalletaddress"). hex())': command not found

But when I replaced the variables with literals and removed the double quotes around the entire string (including the double quote behind python3), everything worked. So my question became, how to expand the variables without having to have the double quotes around the entire string. This proved tricky (for me at least) but I finally resolved it like this:

PUZZLEHASHEXEC=$(echo "python3 -c 'import $FORKNAME.util.bech32m as b; print(b.decode_puzzle_hash(\""$WALLETADDRESS"\"). hex())'")


The eval was the key.

Anyway, thanks all for spending the time to try to help!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .