EconForge / interpolation.py

BSD 2-Clause "Simplified" License
124 stars 35 forks source link

BUG: build problem with conda. #14

Closed albop closed 6 years ago

albop commented 8 years ago

Trying to bulid conda packages yields some error linked to the njit(cache=true) option:

RuntimeError: cannot cache function 'solve_deriv_interp_1d': no locator available for file '/home/travis/miniconda/envs/test-environment/lib/python3.5/site-packages/interpolation-0.1.6-py3.5.egg/interpolation/splines/filter_cubic.py'

Not sure where it comes from and I haven't been able to produce a smaller self contained example.

albop commented 8 years ago

This was fixed in commit https://github.com/EconForge/interpolation.py/commit/6b683b70eb78e254a4a997be7fde53137971ca40 by avoiding the creation of an egg directory.

fheday commented 6 years ago

I am having a similar problem without using conda:

`RuntimeError Traceback (most recent call last)

in () ----> 1 interp = CubicSpline([0.0, 0.0, 0.0], [1, 1, 1],[5, 5, 5],dd[:,-1]) /usr/lib/python3.6/site-packages/interpolation-0.1.9-py3.6.egg/interpolation/splines/splines.py in __init__(self, a, b, orders, values) 47 48 if values is not None: ---> 49 self.set_values(values) 50 51 /usr/lib/python3.6/site-packages/interpolation-0.1.9-py3.6.egg/interpolation/splines/splines.py in set_values(self, values) 55 values = np.array(values, dtype=float) 56 ---> 57 from .filter_cubic import filter_coeffs 58 59 if not np.all( np.isfinite(values)): /usr/lib/python3.6/importlib/_bootstrap.py in _find_and_load(name, import_) /usr/lib/python3.6/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_) /usr/lib/python3.6/importlib/_bootstrap.py in _load_unlocked(spec) /usr/lib/python3.6/importlib/_bootstrap.py in _load_backward_compatible(spec) /usr/lib/python3.6/site-packages/interpolation-0.1.9-py3.6.egg/interpolation/splines/filter_cubic.py in () 9 10 ---> 11 @njit(cache=True) 12 def solve_deriv_interp_1d(bands, coefs): 13 /usr/lib/python3.6/site-packages/numba/decorators.py in wrapper(func) 189 **dispatcher_args) 190 if cache: --> 191 disp.enable_caching() 192 if sigs is not None: 193 # Register the Dispatcher to the type inference mechanism, /usr/lib/python3.6/site-packages/numba/dispatcher.py in enable_caching(self) 527 528 def enable_caching(self): --> 529 self._cache = FunctionCache(self.py_func) 530 531 def __get__(self, obj, objtype=None): /usr/lib/python3.6/site-packages/numba/caching.py in __init__(self, py_func) 612 def __init__(self, py_func): 613 self._name = repr(py_func) --> 614 self._impl = self._impl_class(py_func) 615 self._cache_path = self._impl.locator.get_cache_path() 616 # This may be a bit strict but avoids us maintaining a magic number /usr/lib/python3.6/site-packages/numba/caching.py in __init__(self, py_func) 347 else: 348 raise RuntimeError("cannot cache function %r: no locator available " --> 349 "for file %r" % (qualname, source_path)) 350 self._locator = locator 351 # Use filename base name as module name to avoid conflict between RuntimeError: cannot cache function 'solve_deriv_interp_1d': no locator available for file '/usr/lib/python3.6/site-packages/interpolation-0.1.9-py3.6.egg/interpolation/splines/filter_cubic.py'`
albop commented 6 years ago

OH no ! @fheday, could you print the output of conda info and conda list | grep numba ?

fheday commented 6 years ago

Sure, (but I am running it without conda) here it is:

`$  /opt/anaconda/bin/conda info

 active environment : None
   user config file : /home/heday/.condarc

populated config files : /home/heday/.condarc conda version : 4.5.4 conda-build version : 3.10.5 python version : 3.6.5.final.0 base environment : /opt/anaconda (read only) channel URLs : https://conda.anaconda.org/conda-forge/linux-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/linux-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/pro/linux-64 https://repo.anaconda.com/pkgs/pro/noarch package cache : /opt/anaconda/pkgs /home/heday/.conda/pkgs envs directories : /home/heday/.conda/envs /opt/anaconda/envs platform : linux-64 user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Linux/4.17.2-1-ARCH arch/rolling glibc/2.27 UID:GID : 1000:1000 netrc file : None offline mode : False $  /opt/anaconda/bin/conda list |grep numba numba 0.38.0 py36h637b7d7_0`

fheday commented 6 years ago

My system's numba is: python-numba 0.38.0-1

My python version: python 3.6.5-3

royan18 commented 6 years ago

Having the same issue. How can I resolve it?

conda info below: My numba version is 0.35.0

active environment : base active env location : C:\ProgramData\Anaconda3 shell level : 1 user config file : C:\Users\royan18.condarc populated config files : conda version : 4.5.5 conda-build version : 3.0.27 python version : 3.6.3.final.0 base environment : C:\ProgramData\Anaconda3 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/win-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/pro/win-64 https://repo.anaconda.com/pkgs/pro/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\ProgramData\Anaconda3\pkgs C:\Users\royan18\AppData\Local\conda\conda\pkgs envs directories : C:\ProgramData\Anaconda3\envs C:\Users\royan18\AppData\Local\conda\conda\envs C:\Users\royan18.conda\envs platform : win-64 user-agent : conda/4.5.5 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.17134 administrator : True netrc file : None offline mode : False

albop commented 6 years ago

@royan18, @fheday : sorry I let that one slip. I have reopened the issue. I gather you are both using windows and installed from the github directory with pip install . (since latest version on pypi is 0.1.6). Can you give me the precise command which triggers the error message ? That is not clear from the discussion above.

royan18 commented 6 years ago

@albop The error happened when I was trying to run f_intp = CubicSpline(a, b, orders, data). I think @fheday had a similar situation.

albop commented 6 years ago

Si I assume data has the right dimension ? (I.e. data.ndim==a.shape[0]) Trouble is I can't replicate the problem on my laptop. How did you install the package ? (Pip, python setup.py, conda...)

Le ven. 13 juil. 2018 à 22:24, royan18 notifications@github.com a écrit :

@albop https://github.com/albop The error happened when I was trying to run f_intp = CubicSpline(a, b, orders, data). I think @fheday https://github.com/fheday had a similar situation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EconForge/interpolation.py/issues/14#issuecomment-404944001, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5KXmRIkVf92PJ4e7RaGAqxxjLXfvGks5uGQH-gaJpZM4Iq6U9 .

royan18 commented 6 years ago

I installed the package using the command python setup.py install Let me give you a more clear context. I followed the instructions in the Notebook, but I didn't fail until section In [9] when running interp = CubicSpline(a,b,orders,vals). Is it a better example?

albop commented 6 years ago

Thanks. Would you mind reinstalling and reinstalling with pip install and check whether it solves the problem ?

Le ven. 13 juil. 2018 à 23:52, royan18 notifications@github.com a écrit :

I installed the package using the command python setup.py install Let me give you a more clear context. I followed the instructions in the Notebook https://github.com/EconForge/interpolation.py/blob/master/examples/cubic_splines_python.ipynb, but I didn't fail until section In [9] when running interp = CubicSpline(a,b,orders,vals). Is it a better example?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EconForge/interpolation.py/issues/14#issuecomment-404963328, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5Kd9emwcI6NmFIx8bEKkb-CiUtd_Aks5uGRaQgaJpZM4Iq6U9 .

albop commented 6 years ago

I mean "pip install ." from within the cloned directorynot pulling from pypi

Le ven. 13 juil. 2018 à 23:53, Pablo Winant pablo.winant@gmail.com a écrit :

Thanks. Would you mind reinstalling and reinstalling with pip install and check whether it solves the problem ?

Le ven. 13 juil. 2018 à 23:52, royan18 notifications@github.com a écrit :

I installed the package using the command python setup.py install Let me give you a more clear context. I followed the instructions in the Notebook https://github.com/EconForge/interpolation.py/blob/master/examples/cubic_splines_python.ipynb, but I didn't fail until section In [9] when running interp = CubicSpline(a,b,orders,vals). Is it a better example?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EconForge/interpolation.py/issues/14#issuecomment-404963328, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5Kd9emwcI6NmFIx8bEKkb-CiUtd_Aks5uGRaQgaJpZM4Iq6U9 .

royan18 commented 6 years ago

Okay, but I got an error when installing:

C:\interpolation.py-master>pip install setup.py Collecting setup.py Could not find a version that satisfies the requirement setup.py (from versions: ) No matching distribution found for setup.py

Please advice whether I use the correct path and command.

albop commented 6 years ago

Move to the same directory where setup my is. Then type "pip install ."

Le sam. 14 juil. 2018 à 00:30, royan18 notifications@github.com a écrit :

Okay, but I got an error when installing:

C:\interpolation.py-master>pip install setup.py Collecting setup.py Could not find a version that satisfies the requirement setup.py (from versions: ) No matching distribution found for setup.py

Please advice whether I use the correct path and command.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EconForge/interpolation.py/issues/14#issuecomment-404969715, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5KTgm2nE6lyxIDz0txvlpkx7BLgdsks5uGR9qgaJpZM4Iq6U9 .

royan18 commented 6 years ago

Sorry I missed your previous message. Tried pip install . and now it works! Thanks so much @albop

albop commented 6 years ago

For the record, I got a plausible explanation of what was happening there. By default setup.py creates a zip archive of the library which is then copied in the python installation directory. Then the intepreter mounts this archive and reads files from it transparently. But it cannot write into it, which is a problem for numba because that is where the cached jitted functions are written.

There seems to be a fix for that: add the option zip_safe=False to the setup.py file. @royan18 : would you horribly mind trying whether python setup.py install would work with this modification ?

MaximilianHoffmann commented 6 years ago

Adding zip_safe=False to setup.py resolves the issue!

albop commented 6 years ago

Thanks @MaximilianHoffmann . I've merged the amended setup.py in master.