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.
2
Answers
Are you sure that Pyomo is installed and available in your Python environment. Run
pip list
in your terminal and see a list of all installed packages.If Pyomo is not listed, you can install it by running
pip install pyomo
.You should choose the correct interpreter for vscode.
Ctrl+Shift+P –> Python:Select Interpreter
Verify your output interpreter with the following code.
You can also use the obtained full path to install
pyomo