question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No module named using virtual environment in VS Code

See original GitHub issue

Environment 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:

image

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:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Dec 21, 2017

yes i run from the terminal window in VSCode

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.

0reactions
melzoghbicommented, Jan 9, 2018

Thanks this helps @DonJayamanne .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import Errors in Python: No Module Named “Module_Name ...
Firstly, open up visual studio code and in your terminal check whether you are in your virtual environment. You can move into your...
Read more >
No module named 'requests' using venv in vscode - Stack ...
I have encountered a similar problem such as yours but was able to solve it by changing the workspace settings python path to...
Read more >
No module named using virtual environment in VS Code #428
I am expecting to run this app in VS Code with no issues as i run it on IPython on the same machine...
Read more >
Using Python environments in VS Code
From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing ...
Read more >
ModuleNotFoundError: No module named 'virtualenv' in Python
The Python "ModuleNotFoundError: No module named 'virtualenv'" occurs when we forget to install the virtualenv module before importing it or install it in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found