Calling Python from bash: Difference between revisions
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
Check out these links for the meaning of [[Python_Language_Modularization#Standalone_Program|standalone Python program]] and [[Python_Language_Modularization#Python_Script|Python script]]. | Check out these links for the meaning of [[Python_Language_Modularization#Standalone_Program|standalone Python program]] and [[Python_Language_Modularization#Python_Script|Python script]]. | ||
==Using the Interpreter from the a Virtual Environment== | |||
<font color=darkkhaki> | |||
TODO | |||
If you want to use the interpreter from a specific virtual environment instead of the interpreter found in PATH, explicitly use the path to the binary from the virtual environment directory: | |||
<syntaxhighlight lang='bash'> | |||
$(dirname $0)/venv/bin/python ... | |||
</syntaxhighlight> | |||
</font> | |||
=Inline Python Code= | =Inline Python Code= | ||
Use bash [[Bash_Input/Output#Here-Docs|here-doc]]: | Use bash [[Bash_Input/Output#Here-Docs|here-doc]]: |
Revision as of 16:57, 2 May 2023
Internal
Overview
This article summarizes a series of aspects related to invoking Python program from bash.
Running a Python Program with a Bash Wrapper
Check out these links for the meaning of standalone Python program and Python script.
Using the Interpreter from the a Virtual Environment
TODO
If you want to use the interpreter from a specific virtual environment instead of the interpreter found in PATH, explicitly use the path to the binary from the virtual environment directory:
$(dirname $0)/venv/bin/python ...
Inline Python Code
Use bash here-doc:
python3 <<EOF
print('blah')
EOF
Also see: