Closed mtryan83 closed 4 months ago
Seems to work OK for me in 3.11.5. Did you install cobaya e.g. with "pip install -e "?
Please close if this is OK, otherwise a reproducing case would be helpful.
Ah, my mistake, I should have mentioned I was installing from source. A coworker gave the impression they were seeing the issue when installing normally, but from further testing I've had no trouble when installing from pip.
Reproducing seems pretty straightforward (slightly tweaked from the install instructions since I use conda
):
# Create install environment
$ conda create -n cobaya_test numpy scipy pandas pyyaml requests pybobyqa getdist fuzzywuzzy packaging tqdm portalocker dill
# Clone source
$ git clone https://github.com/CobayaSampler/cobaya.git
# Install (we don't need the test requisites)
pip install --no-deps -e cobaya
# Try to install cosmology packs
$ cobaya-install cosmo -p cobaya-packs/
Traceback (most recent call last):
File "/$HOME/.conda/envs/cobaya_test/bin/cobaya-install", line 8, in <module>
sys.exit(install_script())
^^^^^^^^^^^^^^^^
File "/$HOME/cobaya/cobaya/install.py", line 564, in install_script
warn_deprecation()
File "/$HOME/cobaya/cobaya/tools.py", line 719, in warn_deprecation
warn_deprecation_version(logger=logger)
File "/$HOME/cobaya/cobaya/tools.py", line 712, in warn_deprecation_version
from cobaya import __obsolete__
ImportError: cannot import name '__obsolete__' from 'cobaya' (unknown location)
The pip install
command is slightly different from the install instructions, but I get the same result regardless. As far as I know, using conda shouldn't be an issue (it isn't when I install directly from pip).
To be honest, I'm not even sure this requires a code change, since it's a little obscure, but it would be nice to have at least a note in the documentation about it.
Thanks but I can't reproduce it with that. (pybobyqa are not default conda packages, and you don't seem to switch environment). This works for me.
$ conda create -n cobaya_test numpy scipy pandas pyyaml requests fuzzywuzzy packaging tqdm portalocker dill
$ activate cobaya_test
$ pip install -e cobaya
$ cobaya-install cosmo -p cobaya-packs/
At some point between 3.8 and 3.10(?) python seems to have changed how modules are initialized and the variables found in
cobaya/cobaya/__init__.py
are no longer exported under e.g.from cobaya import __obsolete__
unless you are running from the cobaya directory itself. Thus, running the example codefails with the error
ImportError: cannot import name '__obsolete__' from 'cobaya' (unknown location)
.A workaround (for this problem specifically, may apply to other issues) is to change
on line 712 in
cobaya/cobaya/tools.py
toSince this might not be the correct/best fix, I haven't made it a PR.