spex-xray / spex-help

These are the help and manual pages for the SPEX X-ray spectral fitting package.
1 stars 1 forks source link

Pyspex is not loaded in Jupyter notebook #32

Open sinancankara opened 1 year ago

sinancankara commented 1 year ago

Hi Jelle,

I am trying to use pyspex with Jupyter notebook. For the installation I followed the AHEAD2020 School documentation. I selected the spex kernel, but I get the error in this entry: https://github.com/spex-xray/spex-help/issues/6#issue-727980389

Kernel is installed according to the comment and pyspex works when I run python.

Also I tried SciServer installation and running the notebook there, but I get the same error.

Thank you!

Best, Sinancan

jdeplaa commented 1 year ago

Hi Sinancan,

The reason for the error may be different for both methods. Let me give some advice for both situations separately:

SPEX on local machine:

SPEX on Sciserver.org:

I hope these tips work for you. I will also add them to the school webpage.

sinancankara commented 1 year ago

Hi Jelle,

Thank you for the quick reply.

I forgot to mention but I use WSL Ubuntu enviornment. However, the exact same problem occured when tried on regular Ubuntu. The command which jupyter gave /home/sinancan/.local/bin/jupyter. When I tried $CONDA_PREFIX/bin/jupyter notebook &, it is able to find the pyspex. However this time I get this error and couldn't find a way to resolve it:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[9], line 1
----> 1 from pyspex.spex import Session
      2 s=Session()

File ~/miniconda3/envs/spex/opt/spex/python/pyspex/__init__.py:3
      1 #!/usr/bin/env python
----> 3 from .spex import Session

File ~/miniconda3/envs/spex/opt/spex/python/pyspex/spex.py:16
     12 from future import standard_library
     14 standard_library.install_aliases()
---> 16 from . import pyspex_f2py
     17 from . import data
     18 from . import model

ImportError: cannot import name 'pyspex_f2py' from partially initialized module 'pyspex' (most likely due to a circular import) (/home/sinancan/miniconda3/envs/spex/opt/spex/python/pyspex/__init__.py)

Also, it does work when I try a basic python session.

I tried stopping and running the image but it does not work. I get the same error.

It also works when I try a basic python session on Sciserver.org, the problem is in Jupyter notebook session.

Thank you!

Best, Sinancan

jdeplaa commented 1 year ago

Dear Sinancan,

Thanks for sharing the issues that you encounter. Please try the things below and let me know the outcome.

For your local install:

For the Sciserver.org install:

I hope some of the tips above help.

sinancankara commented 1 year ago

Hi Jelle,

For the Sciserver.org install:

Apologizes, I misinterpreted the modification part as if you have already modified the kernel.json. I did the modification and now it works perfectly.

For the local install:

I had done the regular installation before but the regularly installed SPEX is not sourced. echo $LD_LIBRARY_PATH gives only one enviornment /home/sinancan/miniconda3/envs/spex/opt/spex/lib. This is after executing conda activate spex

Deactivating conda gives this paths:

sinancan@LAPTOP-QLUE2VU1:~$ echo $LD_LIBRARY_PATH
/home/sinancan/heasoft-6.31.1/x86_64-pc-linux-gnu-libc2.35/lib::/home/sinancan/miniconda3/envs/spex/opt/spex/lib:/home/sinancan/miniconda3/envs/spex/opt/spex/lib

Thank you for your help.

jdeplaa commented 1 year ago

Great that the Sciserver installation is running now! :)

Regarding the local install:

sinancankara commented 1 year ago

Yes, thanks! :)

Unfortunately removing .local path did not solve the issue on local machine.