jobovy / galpy

Galactic Dynamics in python
https://www.galpy.org
BSD 3-Clause "New" or "Revised" License
226 stars 98 forks source link

deepcopy error when trying to load galpy potential #657

Closed lmwidrow closed 3 months ago

lmwidrow commented 3 months ago

I was having trouble using some of the potentials (e.g., AnyRazorThin....) and tried uninstall and then install galpy with pip and conda. Either way I now get the following error


TypeError Traceback (most recent call last)

in ----> 1 from galpy.potential import NFWPotential ~/anaconda/lib/python3.6/site-packages/galpy/potential.py in 1 import warnings ----> 2 from galpy.util import galpyWarning 3 warnings.warn("A major change in versions > 1.1 is that all galpy.potential functions and methods take the potential as the first argument; previously methods such as evaluatePotentials, evaluateDensities, etc. would be called with (R,z,Pot), now they are called as (Pot,R,z) for greater consistency across the codebase",galpyWarning) 4 from galpy.potential_src import InPlanePotential 5 from galpy.potential_src import PerpendicularPotential ~/anaconda/lib/python3.6/site-packages/galpy/util/__init__.py in 8 import scipy.linalg as linalg 9 ---> 10 from ..util.config import __config__ 11 12 _SHOW_WARNINGS = __config__.getboolean("warnings", "verbose") ~/anaconda/lib/python3.6/site-packages/galpy/util/config.py in 78 # but don't want to apply changes that we don't want to re-write 79 configfilename = cfilename[-1] ---> 80 __orig__config__ = copy.deepcopy(__config__) 81 82 ~/anaconda/lib/python3.6/copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~/anaconda/lib/python3.6/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 278 if state is not None: 279 if deep: --> 280 state = deepcopy(state, memo) 281 if hasattr(y, '__setstate__'): 282 y.__setstate__(state) ~/anaconda/lib/python3.6/copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~/anaconda/lib/python3.6/copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~/anaconda/lib/python3.6/copy.py in deepcopy(x, memo, _nil) 159 copier = getattr(x, "__deepcopy__", None) 160 if copier: --> 161 y = copier(memo) 162 else: 163 reductor = dispatch_table.get(cls) TypeError: cannot deepcopy this pattern object
jobovy commented 3 months ago

I think the issue here is that you are using a version of Python that is too old and not supported by the latest version of galpy (and that hasn't been supported for more than a year I think). The minimum Python version for galpy is 3.8; most major packages like numpy and astropy are even on a minimum version of 3.10 these days. So what's happening is that you are installing an old version of galpy and that likely leads to this weird error. So you should upgrade your Python installation (easy using conda), no reason not to just go to 3.12 these days.

lmwidrow commented 3 months ago

Yep. That was it. Thanks.


From: Jo Bovy @.> Sent: Friday, June 28, 2024 9:56 AM To: jobovy/galpy @.> Cc: Lawrence Widrow @.>; Author @.> Subject: Re: [jobovy/galpy] deepcopy error when trying to load galpy potential (Issue #657)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

I think the issue here is that you are using a version of Python that is too old and not supported by the latest version of galpy (and that hasn't been supported for more than a year I think). The minimum Python version for galpy is 3.8; most major packages like numpy and astropy are even on a minimum version of 3.10 these days. So what's happening is that you are installing an old version of galpy and that likely leads to this weird error. So you should upgrade your Python installation (easy using conda), no reason not to just go to 3.12 these days.

— Reply to this email directly, view it on GitHubhttps://github.com/jobovy/galpy/issues/657#issuecomment-2196984794, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFYSF7DKV4IK5OHJZA7BPWTZJVTRPAVCNFSM6AAAAABKB6NUN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWHE4DINZZGQ. You are receiving this because you authored the thread.Message ID: @.***>