No module named using virtual environment in VS Code
See original GitHub issueEnvironment data
VS Code version: 1.19.0 Python Extension version: 0.2.3 Python Version: 3.6.3 OS and version: Windows 10 x64 bit
I am trying to run python app that runs on a virtual environment perfectly with no issues. When i copy this code to run in VS Code as azure function i get the following error:
from fbprophet import Prophet\r\nModuleNotFoundError: No module named ‘fbprophet’\r\n",“errorDetails”:"Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.MLLoaderInsight
I am expecting to run this app in VS Code with no issues as i run it on IPython on the same machine using the same virtual environment.
Full code of the app to test loading a prophet model in azure function app in VS Code:
import pickle
from fbprophet import Prophet
# load the model from disk
filename = "c:/prophet_quickstart_model.sav"
with open(filename, "rb") as input_file:
m=pickle.load(input_file)
future = m.make_future_dataframe(periods=100)
future.tail()
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
A screen shot below shows the selected virtual envionment in VS Code which case prophet package:
Output from TERMINAL
Window in VS Code:
Response Status Code: InternalServerError
{"id":"9fbd89de-bf6c-4d35-b8b7-46c43ebe6151","requestId":"50d80248-c769-496d-a587-95730e5065cc","statusCode":500,"errorCode":0,"messsage":"Exception while executing function: Functions.MLLoaderInsight -> Traceback (most recent call last):\r\n File \"C:\\ColumbiaCode\\InsightsPython\\MLLoaderInsight\\run.py\", line 3, in <module>\r\n from fbprophet import Prophet\r\nModuleNotFoundError: No module named 'fbprophet'\r\n","errorDetails":"Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.MLLoaderInsight ---> System.ApplicationException : Traceback (most recent call last):\r\n File \"C:\\ColumbiaCode\\InsightsPython\\MLLoaderInsight\\run.py\", line 3, in <module>\r\n from fbprophet import Prophet\r\nModuleNotFoundError: No module named 'fbprophet'\r\n\r\n at async Microsoft.Azure.WebJobs.Script.Description.ScriptFunctionInvoker.ExecuteScriptAsync(String path,String arguments,Object[] invocationParameters,FunctionInvocationContext context)\r\n at async Microsoft.Azure.WebJobs.Script.Description.ScriptFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context)\r\n at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.InvokeAsync[TReflected](Object[] arguments)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,Object[] invokeParameters,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,ILogger logger,CancellationTokenSource functionCancellationTokenSource)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) \r\n End of inner exception\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)\r\n at Microsoft.Azure.WebJobs.Host.Executors.ExceptionDispatchInfoDelayedException.Throw()\r\n at async Microsoft.Azure.WebJobs.JobHost.CallAsyncCore(MethodInfo method,IDictionary`2 arguments,CancellationToken cancellationToken)\r\n
at async Microsoft.Azure.WebJobs.Script.ScriptHost.CallAsync(String method,Dictionary`2 arguments,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager.HandleRequestAsync(FunctionDescriptor function,HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ProcessRequestAsync(HttpRequestMessage request,FunctionDescriptor function,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.<>c__DisplayClass3_0.<ExecuteAsync>b__0(??)\r\n at async Microsoft.Azure.WebJobs.Extensions.Http.HttpRequestManager.ProcessRequestAsync(HttpRequestMessage request,Func`3 processRequestHandler,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)\r\n at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.SystemTraceHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.WebScriptHostHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)"}
Any help is appreciated.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
Top GitHub Comments
This would lead us to a simple conclusion that this issue isn’t related to the Python extension. As the terminal is something that is part of the core VS Code editor. I’d suggest you raise this issue in the Azure CLI tools repo.
Thanks this helps @DonJayamanne .