Open transreductionist opened 2 months ago
Somewhat expectedly, I cannot reproduce this. I will keep trying to do so, but my suspicion is that there may be something in your environment that is to blame. Can you try to create a virtual environment and see what happens?
This is how I do so on a Mac:
python -m venv virtual-python
source virtual-python/bin/activate
pip install pyomo
# Run your script
Here are some instructions that include Windows: https://www.geeksforgeeks.org/creating-python-virtual-environment-windows-linux/
I will look at it again.
On Wed, Jul 17, 2024, 11:47 Miranda Mundt @.***> wrote:
Somewhat expectedly, I cannot reproduce this. I will keep trying to do so, but my suspicion is that there may be something in your environment that is to blame. Can you try to create a virtual environment and see what happens?
This is how I do so on a Mac:
python -m venv virtual-python source virtual-python/bin/activate pip install pyomo
Run your script
Here are some instructions that include Windows: https://www.geeksforgeeks.org/creating-python-virtual-environment-windows-linux/
— Reply to this email directly, view it on GitHub https://github.com/Pyomo/pyomo/issues/3320#issuecomment-2233636937, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBR5L3VMZNV3TPCSGFWBD3ZM2GXTAVCNFSM6AAAAABK43KJV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZTGYZTMOJTG4 . You are receiving this because you authored the thread.Message ID: @.***>
Summary
I ran a very simple Python script (see below) that imports
pyomo.environ
. When executing the script I received the following error:TypeError: 'tuple' object does not support item assignment
Steps to reproduce the issue
The Python script to reproduce the error:
Error Message
Information on your system
Pyomo version: 6.7.3 Python version: 3.11.8 Operating system: Windows 10 Enterprise with OS build=19045.4529 How Pyomo was installed: PyPy Solver (if applicable): N/A
Additional information
An exception occurs in the file core.base.component.py. Here is the function
__getstate__
with docstring and comments dropped:Consider the code snippet from
__getstate__
:the variable
state
is a tuple with 2 elements. The variableself.__dict__
is a dictionary with 16 items. When the line:for key, val in iteritems(self.__dict__):
is executed and the key is 'init_domain' the statement
if key not in state
is true by construction.The key
'init_domain'
will never be in the tuplestate
, but will be instate[0]
, which is a dictionary.