0

Currently I'm running this command in terminal:

source /home/protected/env/bin/activate

And then I run this and it works:

python3 /home/protected/ethereum-wallet-generator.py

But it seems like it should be required to enter source /home/protected/env/bin/activate first. Is it not possible to specify the path somewhere within the python script or at least a way to turn this into a one-liner instead of having to send 2 separate commands?

1
  • A 2-line batch file or shell script could do this, and you could call the batch file/script with a one-line command. Commented Oct 9, 2018 at 20:10

1 Answer 1

2

Yes, it is possible. You can just change the shebang to this

#!/home/protected/env/bin/python

Then you invoke the script like so (this is your one-liner)

/home/protected/ethereum-wallet-generator.py

Note that it needs to be executable, you can change it like this

chmod u+x /home/protected/ethereum-wallet-generator.py

If you invoke the python interpreter inside the Virtual Environment, it will act as if the activate script was first sourced. Note that you don't even need to specify "python3", but can just go "python"

Sign up to request clarification or add additional context in comments.

4 Comments

Tried that and got this error: Traceback (most recent call last): File "/home/protected/ethereum-wallet-generator.py", line 7, in <module> import sha3 ModuleNotFoundError: No module named 'sha3'
How do you invoke the script?
I'm just running python3 /home/protected/ethereum-wallet-generator.py
I see where you said to just run /home/protected/ethereum-wallet-generator.py instead of what I was doing. Thanks it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.