andreatramacere / jetset

JetSeT a framework for self-consistent modeling and fitting of astrophysical relativistic jets
BSD 3-Clause "New" or "Revised" License
30 stars 15 forks source link

Dependency conflict with NumPy and Numba versions with conda installation #79

Closed Sushanth99 closed 9 months ago

Sushanth99 commented 9 months ago

After installing jetset in the new conda environment by following the installation instructions, I am facing the following issue while importing the Jet class.

MacOS version: 12.7.1 NumPy version: 1.21.6 Numba version: 0.58.0 Jetset version: 1.2.2

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 from jetset.jet_model import Jet
      2 my_jet = Jet(name='test', electron_distribution='lppl',)

File ~/anaconda3/envs/jetset/lib/python3.9/site-packages/jetset/jet_model.py:25
     23 from .jet_paramters import *
     24 from .jet_emitters import *
---> 25 from .jet_emitters_factory import EmittersFactory
     26 from .jet_tools import *
     27 from .mathkernel_helper import bessel_table_file_path

File ~/anaconda3/envs/jetset/lib/python3.9/site-packages/jetset/jet_emitters_factory.py:4
      1 __author__ = "Andrea Tramacere"
      3 import numpy as np
----> 4 import numba as nb
      5 import pprint
      6 from jetset.jet_emitters import EmittersDistribution, InjEmittersDistribution

File ~/anaconda3/envs/jetset/lib/python3.9/site-packages/numba/__init__.py:55
     50             msg = ("Numba requires SciPy version 1.0 or greater. Got SciPy "
     51                    f"{scipy.__version__}.")
     52             raise ImportError(msg)
---> 55 _ensure_critical_deps()
     56 # END DO NOT MOVE
     57 # ---------------------- WARNING WARNING WARNING ----------------------------
     60 from ._version import get_versions

File ~/anaconda3/envs/jetset/lib/python3.9/site-packages/numba/__init__.py:40, in _ensure_critical_deps()
     37 if numpy_version < (1, 22):
     38     msg = (f"Numba needs NumPy 1.22 or greater. Got NumPy "
     39            f"{numpy_version[0]}.{numpy_version[1]}.")
---> 40     raise ImportError(msg)
     41 elif numpy_version > (1, 25):
     42     raise ImportError("Numba needs NumPy 1.25 or less")

ImportError: Numba needs NumPy 1.22 or greater. Got NumPy 1.21.

I tried installing a different version of NumPy. But the pip pointed out the following dependency conflicts:

jetset 1.2.2 requires numpy<1.22,>=1.18, but you have numpy 1.26.2 which is incompatible.
numba 0.58.0 requires numpy<1.26,>=1.21, but you have numpy 1.26.2 which is incompatible.

This suggests numba 0.58.0 would support numpy 1.21.6, so the above ImportError is puzzling. Request any thoughts or suggestions regarding this issue.

andreatramacere commented 9 months ago

Hi @Sushanth99, are installing from the source or directly the binaries from conda? Are you mixing conda and pip with conda-installed package?

Sushanth99 commented 9 months ago

I am using conda directly. I followed the conda installation documentation. The command conda install -c andreatramacere jetset is not working for me. So as suggested in README.md, I used conda install -c andreatramacere -c astropy -c conda-forge 'jetset>=1.2'. This worked for the installation. However, as mentioned above, I am getting an ImportError suggesting a dependency issue.

After that, I tried installing a different version of NumPy using pip, hoping to resolve the dependency issue. But pip showed the dependency conflicts mentioned in the second code block in my opening comment.

andreatramacere commented 9 months ago

The problem is numba, that is messing up always dependencies (it happens often)

In any case, If you use pip to change the version of a conda-installed packages it will not work in general and will alternate your environment. You can use pip in conda, but you should not use pip to change version of packages installed by conda

The install instructions of jetset are here: https://jetset.readthedocs.io/en/latest/install.html The ones on git are mostly for developers, or when installing from source

In any case, I suggest the remove the jetset env you created and start from scratch

if the problem is still there, using conda downgrade mamba to 0.57: conda install mamba=0.57

Let me know if it works

Sushanth99 commented 9 months ago

Thanks @andreatramacere. Installing numba=0.57 instead of 0.58 worked.