SasView / sasmodels

Package for calculation of small angle scattering models using OpenCL.
BSD 3-Clause "New" or "Revised" License
16 stars 28 forks source link

ModuleNotFoundError: No module named 'sas' #467

Closed Synthos closed 2 years ago

Synthos commented 3 years ago

Hi everyone

I am trying to use the sasmodels library as a stand alone package in PyCharm.

So far, I tried different approaches, like simply installing sasmodels over the IDE. However, when I try to e.g. load some data with:

from sasmodels import data foo = data.load_data('file_name')

I receive the following error: ModuleNotFoundError: No module named 'sas'

I then deleted the project again and followed the description on https://pypi.org/project/sasmodels/ For that, I created a new folder and installed all the conda dependencies as described in the above tutorial. I can run the files such as sasmodels.jitter from the console. But as soon as I open the project in PyCharm it does not work anymore.

I did not find the module 'sas' and installing the sasview model also did not help. Did I understand something fundamentally wrong with regards to what is meant with "stand alone package"?

Did someone experience similar issues? My workstation has the following specs:

MB Pro 13-inch 2020 macOS Big Sur Version 11.4

I appreciate your help. Thanks in advance! :)

KLDwaSiedem commented 3 years ago

Check out the section titled "Fitting Example" in the sasmodels README. [PAK: updated link]

To load the example data, you will need the SAS data loader from the sasview package. This is not yet available on PyPI, so you will need a copy of the SasView source code to run it. Create a directory somewhere to hold the sasview and sasmodels source code, which we will refer to as $SOURCE.

So you need to also download the sasview repo, and add sasview/src to PYTHONPATH. They describe how to do this in the link above. Alternatively you can use sys.path.append('~/sasview/src')

Good luck.

butlerpd commented 3 years ago

Thanks @KLDwaSiedem -- I trust this solves your problem @Synthos? If so we can close this ticket.

pkienzle commented 3 years ago

This process can be simplified by putting sasmodels on pypi (see #273)

butlerpd commented 2 years ago

This process can be simplified by putting sasmodels on pypi (see #273)

I assume you mean sascalc? or perhaps sasdata? pypi is where sasmodels was retrieved from in the first place?

lucas-wilkins commented 2 years ago

I use PyCharm. I have it set up so that src and src/sas are marked as "source directories". If you have the add source directories to python path box checked in the run configuration (spanner icon, or project properties), it should be able to find things.

pkienzle commented 2 years ago

Why do you need src/sas on the path?

It seems like it would cause confusion since it would allow, for example, importing of both sascalc and sas.sascalc.

lucas-wilkins commented 2 years ago

I do it mostly so the pycharm dev tools can pick up locations of files correctly, and the default run configuration works. Might be more than is necessary, but seems fine.

pkienzle commented 2 years ago

I tweaked the error message so that we can close this ticket. We will need to tweak it again once nxsunit and the data loaders are available as a separate package.