Created
February 17, 2024 19:10
-
-
Save ruslanmv/f896a68780b8130903f67dd1dc55d978 to your computer and use it in GitHub Desktop.
Run Python commands with custom python environment in background from Jupyter Notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a shell script | |
script_content = f''' | |
#!/bin/bash | |
source activate automatic | |
"$@" | |
''' | |
# Write the script to a file | |
script_filename = 'run' | |
with open(script_filename, 'w') as script_file: | |
script_file.write(script_content) | |
# Make the script executable | |
!chmod +x 'run' | |
# Run the script | |
!./run python --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment