SDXorg / pysd

System Dynamics Modeling in Python
http://pysd.readthedocs.org/
MIT License
350 stars 89 forks source link

module 'python_utils.types' has no attribute 'ParamSpec' #418

Closed Nesp closed 5 months ago

Nesp commented 1 year ago

Dear all,

I am trying to import pysd and I get the following error: _module 'pythonutils.types' has no attribute 'ParamSpec'

I tried updating my Python, and checking manually if all dependencies were installed. But, I am still getting this error.

Can you help? Thank you!

Nesp commented 1 year ago

I should say I am using a Mac with a Python version 3.8.8

enekomartinmartinez commented 1 year ago

I would say that this could be related to errors in some Python base packages, but not sure. Could you please provide the full errot message please? Could you also provide the packages versions your running, in particular de version of python_utils?

Nesp commented 1 year ago

Dear enekomartinmartinez,

thank you for your help.

This is the full error message.


AttributeError Traceback (most recent call last)

in ----> 1 import pysd 2 3 model = pysd.load('/Users/vnespeca/Desktop/PostDoc/Journal articles/Paper-1/Application/Multi-Model/SDM/SDM.mdl') ~/opt/anaconda3/lib/python3.8/site-packages/pysd/__init__.py in ----> 1 from .pysd import read_vensim, read_xmile, load 2 from .py_backend import functions, statefuls, utils, external 3 from .py_backend.components import Component 4 from ._version import __version__ ~/opt/anaconda3/lib/python3.8/site-packages/pysd/pysd.py in 8 import sys 9 ---> 10 from pysd.py_backend.model import Model 11 12 ~/opt/anaconda3/lib/python3.8/site-packages/pysd/py_backend/model.py in 19 from pysd._version import __version__ 20 ---> 21 from . import utils 22 from .statefuls import DynamicStateful, Stateful 23 from .external import External, Excels, ExtLookup, ExtData ~/opt/anaconda3/lib/python3.8/site-packages/pysd/py_backend/utils.py in 12 from typing import Dict, Set 13 ---> 14 import progressbar 15 import numpy as np 16 import xarray as xr ~/opt/anaconda3/lib/python3.8/site-packages/progressbar/__init__.py in 3 from .__about__ import __author__ 4 from .__about__ import __version__ ----> 5 from .bar import DataTransferBar 6 from .bar import NullBar 7 from .bar import ProgressBar ~/opt/anaconda3/lib/python3.8/site-packages/progressbar/bar.py in 11 from datetime import datetime 12 ---> 13 from python_utils import types 14 15 try: # pragma: no cover ~/opt/anaconda3/lib/python3.8/site-packages/python_utils/__init__.py in ----> 1 from . import ( 2 aio, 3 compat, 4 converters, 5 decorators, ~/opt/anaconda3/lib/python3.8/site-packages/python_utils/decorators.py in 6 T = types.TypeVar('T') 7 TC = types.TypeVar('TC', bound=types.Container[types.Any]) ----> 8 P = types.ParamSpec('P') 9 10 AttributeError: module 'python_utils.types' has no attribute 'ParamSpec' ______________________________________________________________________________ Kind Regards, Vittorio
enekomartinmartinez commented 1 year ago

Thanks, seems that the problem arises with progressbar package. Nevertheless it is imported as progressbar the version that should be used is progressbar2, could you check that you are using progressbar2 or uninstall progressbar and install progressbar2? If you have installed PySD using pip, conda or requirements.txt you should have the correct version. But if you have installed it by hand maybe you may have installed progressbar instead of progressbar2.

Nesp commented 1 year ago

Thanks a lot for your suggestion! I installed it with pip. And checked: I have progressbar2 installed, not progressbar. Here is the additional info about the packages. What am I missing?


Name: python-utils Version: 3.6.0 Summary: Python Utils is a module with some convenient utilities not included with the standard Python install Home-page: https://github.com/WoLpH/python-utils Author: Rick van Hattem Author-email: Wolph@wol.ph License: BSD Location: ... Requires: typing-extensions Required-by: progressbar2


Name: progressbar2 Version: 4.2.0 Summary: A Python Progressbar library to provide visual (yet text based) progress to long running operations. Home-page: https://github.com/WoLpH/python-progressbar Author: Rick van Hattem (Wolph) Author-email: wolph@wol.ph License: BSD Location: ... Requires: python-utils Required-by: pysd

Nesp commented 1 year ago

image

enekomartinmartinez commented 1 year ago

Hi @Nesp

It seems that the problem is more related to progressbar2 dependencies. I have been checking the CI test we are using, and we didn't have that problem. We run them on Windows and Linux with Python3.7 progressbar2-4.2.0 python-utils-3.5.2 and with Python3.10 progressbar2-4.2.0 python-utils-3.6.0. We could add Mac to the CI, but it doesn't make a lot of sense to me as our code doesn't depend on the machine architecture and seems to be a bug related to progressbar2.

I suggest creating a new environment on your computer and installing only progressbar2-4.2.0 with python-utils-3.6.0 and the same Python version you are using. Then, try to import progressbar. If the problem persists, open an issue in their repo, as they set the python-utils dependency.

Feel free to let me know if you need any help in the process, and I could try to help. I am sorry that I don't have a Mac machine or VM to test the issue properly.