PROBLEM WITH PYOMO.CORE

110 views
Skip to first unread message

Amedeo Testori

unread,
Apr 23, 2021, 8:15:00 AM4/23/21
to Temoa Project
Hello,

I'm facing some problems with the creation of the environment conda and some packages are not downloaded automatically. More precisely even if I gave pyomo.core in C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo it does not find it. Please not I'm running temoa_utopia so the code should not provide error by itself.
I report below the error message:

(temoa-py3) (venv) C:\Users\amedeo.testori\Desktop\temoa-energysystem_new>python  temoa_model/  --config=temoa_model/config_sample
Traceback (most recent call last):
  File "temoa_model\temoa_initialize.py", line 31, in <module>
    from pyomo.core import *
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\__init__.py", line 11, in <module>
    from pyomo.core.expr import *
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\expr\__init__.py", line 19, in <module>
    from . import numvalue, numeric_expr, logical_expr, current
  File "pyomo\core\expr\logical_expr.pyx", line 31, in init pyomo.core.expr.logical_expr
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\expr\boolean_value.py", line 8, in <module>
    from pyomo.core.expr.expr_common import _and, _or, _equiv, _inv, _xor, _impl
ImportError: cannot import name '_and' from 'pyomo.core.expr.expr_common' (C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\ex
pr\expr_common.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "temoa_model\__main__.py", line 28, in <module>
    from temoa_model import *
  File "temoa_model\temoa_model.py", line 20, in <module>
    from temoa_rules import *
  File "temoa_model\temoa_rules.py", line 26, in <module>
    from temoa_initialize import *
  File "temoa_model\temoa_initialize.py", line 43, in <module>
    raise ImportError( msg )
ImportError:
Unable to find 'pyomo.core.' Check to make sure pyomo is installed, and that
you are running a version compatible with Temoa.


hope you can help me,
cheers

Amedeo Testori

Joe

unread,
Apr 23, 2021, 8:20:06 AM4/23/21
to Temoa Project
Hi Amedeo,

Sorry to hear you're having trouble. A few follow-up questions:
1. What operating system are you using?
2. What error is given when you install the environment?
3. Have you activated the environment once you've created it? The command is:
$ conda activate temoa-py3 (or whatever you named it)

I always receive the "Unable to find 'pyomo.core'" error when I don't have the Temoa environment activated.

Best,
Joe

Amedeo Testori

unread,
Apr 23, 2021, 11:37:56 AM4/23/21
to Temoa Project
Hi Joe, thanks for your prompt reply!

1. I'm using Windows 10 Home
2. When I install the environment is not giving any error, but I cannot visualize the environment between the ones avaiable in  conda.
3.I did activate the environment once created it.

I leave I attached a screenshot from the Python Interpreter Setting in Pycharm

Thanks 
Amedeo Testori

photo_2021-04-23_15-23-59.jpg

Joe

unread,
Apr 23, 2021, 11:44:51 AM4/23/21
to Temoa Project
Hi Amedeo,

From the Anaconda shell, what happens when you try the following?
$ pyomo solve --help

You should be provided with a description of how to run pyomo. If that doesn't work, it means your system can't find pyomo. In that case, check the pyomo documentation for more help.  If it does work, try solving the model from the anaconda prompt as follows:
$ pyomo solve --solver=cplex temoa_model/temoa_model.py data_files/utopia-15.dat

Let me know what you find.

Best,
Joe

Amedeo Testori

unread,
Apr 25, 2021, 9:21:47 PM4/25/21
to Temoa Project on behalf of Joe
Hello,

writing  $ pyomo solve --help it follow:

  (temoa-py3) C:\Users\amedeo.testori\Desktop\temoa-energysystem_new>pyomo solve --help

Traceback (most recent call last):
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\Scripts\pyomo-script.py", line 6, in <module>
    from pyomo.scripting.pyomo_main import main
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\scripting\__init__.py", line 14, in <module>
    import pyomo.scripting.pyomo_command
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\scripting\pyomo_command.py", line 18, in <module>
    import pyomo.scripting.util
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\scripting\util.py", line 50, in <module>

    from pyomo.core import *
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\__init__.py", line 11, in <module>
    from pyomo.core.expr import *
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\expr\__init__.py", line 19, in <module>
    from . import numvalue, numeric_expr, logical_expr, current
  File "pyomo\core\expr\logical_expr.pyx", line 31, in init pyomo.core.expr.logical_expr
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\expr\boolean_value.py", line 8, in <module>
    from pyomo.core.expr.expr_common import _and, _or, _equiv, _inv, _xor, _impl
ImportError: cannot import name '_and' from 'pyomo.core.expr.expr_common' (C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\ex
pr\expr_common.py)

The same error is given when I digit $ pyomo solve --solver=cplex temoa_model/temoa_model.py data_files/utopia-15.dat in the
anaconda prompt (temoa-py3). 

Does it sounds something to you?

Thanks again
Amedeo Testori

--
You received this message because you are subscribed to the Google Groups "Temoa Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to temoa-projec...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/temoa-project/6d198821-b6a4-45a5-8049-75500bd9d13an%40googlegroups.com.

Joe

unread,
Apr 25, 2021, 9:34:11 PM4/25/21
to Temoa Project
Hi Amedeo,

This is definitely an issue with the pyomo installation, since it throws the same error even when you try to invoke the help function. You may want to try reinstalling the environment. I suspect it may have to do with pyutilib, which you mentioned in a previous email that you had to install manually. Your versions of pyomo and pyutilb may be out of sync. As noted in the environment file, Temoa requires pyomo v5.5 and pyutilib v5.8.

Best,
Joe

Amedeo Testori

unread,
Apr 26, 2021, 7:46:27 AM4/26/21
to Temoa Project on behalf of Joe
Hi!

I have installed the packages passing by the comand:

pip install Pyomo==5.5.0 
pip install PyUtilib==5.8.0

Now the error launching temoa is:

(temoa-py3) C:\Users\amedeo.testori\Desktop\temoa-energysystem_new>python  temoa_model/  --config=temoa_model/config_sample

Traceback (most recent call last):
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "temoa_model\__main__.py", line 28, in <module>
    from temoa_model import *
  File "temoa_model\temoa_model.py", line 22, in <module>
    from temoa_run import *
  File "temoa_model\temoa_run.py", line 29, in <module>
    from pyomo.environ import *
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\environ\__init__.py", line 89, in <module>
    _import_packages()
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\environ\__init__.py", line 59, in _import_packages
    _do_import(pname)
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\environ\__init__.py", line 16, in _do_import
    importlib.import_module(pkg_name)
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\__init__.py", line 25, in <module>
    import pyomo.pysp.scenariotree
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\scenariotree\__init__.py", line 18, in <module>
    import pyomo.pysp.scenariotree.manager
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\scenariotree\manager.py", line 969
    async=False,
        ^
SyntaxError: invalid syntax

I don't know if it represents any kind of improvement, it seems so to me.
Wait for your opinion.

Thanks 
Amedeo Testori
htttg


You received this message because you are subscribed to a topic in the Google Groups "Temoa Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/temoa-project/S4oymftYhBE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to temoa-projec...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/temoa-project/7aaf192b-1ddb-4676-a7be-c99df8d6dc61n%40googlegroups.com.

Joe

unread,
Apr 26, 2021, 7:53:51 AM4/26/21
to Temoa Project
Hi Amedeo,

Based on the error, looks like your trying to invoke pysp to do a stochastic run. Can you just try a single run with temoa_utopia.sqlite to see if the installation works, using the config file setup as-is from Github?

Best,
Joe

Amedeo Testori

unread,
Apr 26, 2021, 10:59:17 PM4/26/21
to Temoa Project on behalf of Joe
Hi Joe,

I tried to run temoa_utopia.sqlite with config_sample from Github (it seems to be the same I was running) but the error is always the same:

What do you think about?

Thanks

Amedeo Testori

Joe DeCarolis

unread,
Apr 27, 2021, 7:30:55 AM4/27/21
to Temoa Project
Hi Amedeo,

Can you try the pyomo solve --help command again? I suspect this is an issue with pyomo and not Temoa. If the help command works, then try to solve one of the simple problems in the pyomo gallery. If pyomo passes both those tests, then we can further debug Temoa. If those basic tests fail, then I would recommend a clean install of the Temoa environment or use the Pyomo stack exchange forum, which is linked near the bottom of this page.

Best,
Joe

Amedeo Testori

unread,
May 3, 2021, 9:04:37 AM5/3/21
to Temoa Project on behalf of Joe
hello, sorry for the delay! 

I've tried the command :  pyomo solve --help 

(temoa-py3) C:\Users\amedeo.testori\Desktop\temoa-energysystem_new>pyomo solve --help
Traceback (most recent call last):
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\scripting\pyomo_main.py", line 25, in <module>
    plugin_class = entrypoint.load()
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pkg_resources\__init__.py", line 2450, in load
    return self.resolve()
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pkg_resources\__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\__init__.py", line 25, in <module>
    import pyomo.pysp.scenariotree
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\scenariotree\__init__.py", line 18, in <module>
    import pyomo.pysp.scenariotree.manager
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\scenariotree\manager.py", line 969

    async=False,
        ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\Scripts\pyomo.exe\__main__.py", line 4, in <module>
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\scripting\pyomo_main.py", line 37, in <module>
    raise ImportError(msg)
ImportError: Error loading pyomo.command entry point pyomo.runbenders = pyomo.pysp.benders:
Original SyntaxError: invalid syntax (manager.py, line 969)
Traceback:
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\scripting\pyomo_main.py", line 25, in <module>
    plugin_class = entrypoint.load()
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pkg_resources\__init__.py", line 2450, in load
    return self.resolve()
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pkg_resources\__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\__init__.py", line 25, in <module>
    import pyomo.pysp.scenariotree
  File "c:\users\amedeo.testori\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\pysp\scenariotree\__init__.py", line 18, in <module>
    import pyomo.pysp.scenariotree.manager

I think this means the test have been failed ! So you suggest to pass throught the pyomo forum.

You suggested to go for a clean install of Temoa, what do you mean for that?

Thanks
Cheers

Amedeo Testori

Joe

unread,
May 3, 2021, 9:17:24 AM5/3/21
to Temoa Project
Hi Amedeo,

There's something wrong with your pyomo installation, which was installed as part of the Temoa environment. To try reinstalling, first deactivate the Temoa environment:
$ conda deactivate temoa-py3
And then uninstall it:
$ conda remove --name temoa-py3 --all

Then repeat the steps outlined here to re-install the environment, which includes the version of pyomo known to work with Temoa.

If that doesn't work, then perhaps try the Pyomo forum to see if they can help.

Best,
Joe

Amedeo Testori

unread,
May 8, 2021, 8:57:53 AM5/8/21
to Temoa Project on behalf of Joe
Hi joe, 

While trying to execute this command 


$ conda remove --name temoa-py3 --all

I run into this error (I leave a screenshot attached):

-Invalid Python SDK-
Cannot set up a python SDK at Python 3.7 (temoa-py3 )(C:\Users\amedeo.testori\anaconda3\envs\temoa-py3\python.exe).
The SDK seems invalid.

You know how to solve it? Cause If I press OK it gives me it again after a few seconds. So I got stucked.

Thanks 

Amedeo Testori

Immagine 2021-05-03 161812.png

Joe

unread,
May 17, 2021, 10:26:17 AM5/17/21
to Temoa Project
Hi Amedeo,

Apologies for the slow response. I've not run into this issue before, so not sure how to resolve. It may have to do with your use of PyCharm, which I have not used before. For example, here is a similar issue being discussed on StackOverflow. Perhaps try running the model from the command line rather than through PyCharm to see if it works.

Best,
Joe
Reply all
Reply to author
Forward
0 new messages