我正在制作一个机器学习应用程序,并使用experiment.submit(config)运行一个实验。提交实验时,Python版本在提交脚本和运行脚本的地方都不同。例如,当我提交脚本但不在脚本内时,我可以导入numpy。是否可以在与提交脚本相同的环境下运行脚本?
config.py:
#!/bin/bash
################################################################################
# latest - display latest video frame from Redis cache
################################################################################
# Redis host
host=127.0.0.1
# Get currFrame from Redis
currFrame=$(redis-cli --raw -h $host get currFrame)
redis-cli -h $host get f-$currFrame > current.jpg
open current.jpg
test_script.py:
from azureml.core import ScriptRunConfig
from azureml.core.runconfig import RunConfiguration
from azureml.core.experiment import Experiment
from azureml.core.workspace import Workspace
import numpy as np
import sys
print(sys.version)
ws = Workspace.from_config()
experiment=Experiment(ws, "RandomName")
config = ScriptRunConfig(source_directory='.', script='test_script.py',
run_config=RunConfiguration(script=None, arguments=None, framework=None,
conda_dependencies=None, _history_enabled=None, _path=None, _name=None))
run = experiment.submit(config)
run.wait_for_completion(show_output = True)
当我这样做时:分别在config.py和test_script.py中显示“ print(sys.version)”,我得到以下输出:
import sys
print(sys.version)
import numpy as np
和:
3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)]
我无法在test_script.py中导入numpy。
如果无法在与调用脚本相同的环境中运行脚本,那么我应该怎么做才能访问numpy之类的库?