cfs-energy / radas

Simple Python module to calculate radiation curves from OpenADAS
MIT License
4 stars 3 forks source link

Error when using python 3.9.6 #13

Closed GuanqiDong92 closed 3 months ago

GuanqiDong92 commented 3 months ago
image

I want to install cfspopcon on Mac, but it seems to have failed to start well with the example. Do you have a similar problem?

hassec commented 3 months ago

@GuanqiDong92 Could you post some more details about how one can reproduce this issue? E.g. how was your python environment setup, and what steps did you take to install cfspopcon

tbody-cfs commented 3 months ago

@GuanqiDong92 it looks like you haven't run radas yet. https://cfspopcon.readthedocs.io/en/latest/doc_sources/Usage.html

GuanqiDong92 commented 3 months ago

@GuanqiDong92 Could you post some more details about how one can reproduce this issue? E.g. how was your python environment setup, and what steps did you take to install cfspopcon

hi @hassec , the python version and the environment are as follows

image

As for the installation of cfspopcon, I just use "pip install cfspopcon" following the instruction in https://cfspopcon.readthedocs.io/en/latest/doc_sources/Usage.html as @tbody-cfs commented.

hassec commented 3 months ago

@GuanqiDong92

Can you try running the radas command again with the --verbose flag:

radas --verbose -d ./radas_dir

If that crashes again and drops you into the debugger (ipdb), could you type bt, hit enter and post the resulting backtrace here?

GuanqiDong92 commented 3 months ago

@GuanqiDong92

Can you try running the radas command again with the --verbose flag:

radas --verbose -d ./radas_dir

If that crashes again and drops you into the debugger (ipdb), could you type bt, hit enter and post the resulting backtrace here?

@hassec , here is the result

image
tbody-cfs commented 3 months ago

Hi @GuanqiDong92. Could you try rm -rf ./radas_dir and then rerun the radas --verbose -d ./radas_dir command? This should take about 10-15 mins — it's important to not kill the process while this runs.

It looks like you're missing some of the files needed for the ADAS reader.

GuanqiDong92 commented 3 months ago

Hi @tbody-cfs , it does not work for me.....

image
hassec commented 3 months ago

Thanks @GuanqiDong92. I can reproduce the problem when using python 3.9.6 like you. The reason for the error is that radas is using:

shutil.unpack_archive(output_filename, output_folder, filter="data")

But passing filter='data' is a security patch that only is available to python 3.9.17 and later.

So the easiest workaround would probably be to use a newer python version. We'll fix this on radas, but likely just by requiring a newer python version as passing filter='data' has security benefits.

tbody-cfs commented 3 months ago

@GuanqiDong92 I've opened https://github.com/cfs-energy/radas/pull/14 as a potential fix. You're welcome to try run that version of radas before we get it onto PyPi, following the instructions below

cd .. #change to some folder where you want to install radas
git clone git@github.com:cfs-energy/radas.git
cd radas
git checkout patch_shutil_for_py39
poetry install
poetry run radas --verbose
cd ../cfspopcon #change back to the cfspopcon repository
cp -r ../radas/radas_dir .
poetry run popcon example_cases/SPARC_PRD --show
hassec commented 3 months ago

A new version of cfspopcon has been released: https://pypi.org/project/cfspopcon/6.0.1/ which requires the fixed version of radas. Closing this issue, but if you run in any more problems, please feel free to reopen the issue.

GuanqiDong92 commented 3 months ago

git clone git@github.com:cfs-energy/radas.git

hi @tbody-cfs , when I try "poetry run radas", it comes to the following error..

image

I googled it, it seems clang/gcc have conflicts. But I don't know how to fix it, could you please help?

tbody-cfs commented 3 months ago

How did you install gfortran? I'd suggest using brew install gcc (https://fortran-lang.org/learn/os_setup/install_gfortran/#homebrew)

If you've already done that, can you paste here your which gfortran?

GuanqiDong92 commented 3 months ago

How did you install gfortran? I'd suggest using brew install gcc (https://fortran-lang.org/learn/os_setup/install_gfortran/#homebrew)

If you've already done that, can you paste here your which gfortran?

please forget my last information. After I reinstalled gcc and Python, I redone all the previous steps. However,

image

but I try install importlib-metadata, it did not work...

tbody-cfs commented 3 months ago

Have you run poetry install in the cfspopcon folder?

If there are issues in cfspopcon, please re-open an issue in that repository. Also, for the future, please copy-paste the error message instead of screenshots, since this makes it easier for others to search and find related issues.

GuanqiDong92 commented 3 months ago

Have you run poetry install in the cfspopcon folder?

If there are issues in cfspopcon, please re-open an issue in that repository. Also, for the future, please copy-paste the error message instead of screenshots, since this makes it easier for others to search and find related issues.

@tbody-cfs thank you. it works now after I run poetry install in the cfspopcon folder.