skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. You should choose the correct interpreter for vscode.

    Ctrl+Shift+P –> Python:Select Interpreter

    enter image description here

    Verify your output interpreter with the following code.

    import sys
    print(sys.executable)
    

    You can also use the obtained full path to install pyomo

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search