Search code examples
pythonvisual-studio-codepyomo

VS Code error: Import "pyomo.environ" could not be resolved Pylance(reportMissingImports)


I'm getting the error

Import "pyomo.environ" could not be resolved Pylance(reportMissingImports)

I used to get the same issue with numpy but now only Pyomo is having an issue. I have tried everything online and have not found a solution.

I have tried adding possible Paths to extrapaths in Pylance since I'm assuming that's where the problem is. The directories I added are exactly where Pyomo shows up. I am using Python 3.10 and that is where all my other site-packages are that work and only Pyomo gives me an issue. I've tried re-installing everything associated and I'm not sure why it won't recognize.


Solution

  • I wasn't able to solve the issue, but I did find a work-around where pyomo errors weren't necessary where I could run the python file without errors preventing it from running. Having the additional Python extensions in VSCode I had uninstalled so the Pylance Error wouldn't come up and it seems to work fine.