1 Respuesta
- Más nuevo
- Más votos
- Más comentarios
0
As you mention AWS SageMaker provides its own environment for training models, and I would say it's generally recommended to use that environment rather than creating a separate virtual environment.
However, if you did need to set up the situation above in a file I think you would pull out the code you wrote to a file and then run it via exec
in the main file. Maybe like below, but again not sure its the best/most secure method outside of an example case.
#activate_this.py
import subprocess
import sys
import venv
import os
venv.create("venv", with_pip=True)
subprocess.call(['venv/bin/pip3', "install", "pandas"])
#train.py
activate_this_file = "venv/bin/activate_this.py"
with open(activate_this_file) as f:
code = compile(f.read(), activate_this_file, 'exec')
exec(code, dict(__file__=activate_this_file))
-Zac
respondido hace un año
Contenido relevante
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace 2 años
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace un año
@Zac_D - thanks. i will try this, but one comment on the code you posted, i'm using venv library like you and i don't see this activate_this.py file . i think this file has been discontinued.
To clarify that would be a file you make and save in the same folder.
@Zac D - I've tried to write a script file to activate the virtual environment that is created, but didn't work. can you point me to an example of how one would be writing code to activate it in this activate_this.py file.