Closed ec1340 closed 9 months ago
Hi @ec1340, I am unable to reproduce. It seems like the data repository is empty in your installation. Did you install using pip
, conda
or a local installation from sources ?
What does the content of this folder looks like ?
from medchem import data
print(str(data.__path__[0]))
os.listdir(str(data.__path__[0]))
Or in your case, maybe just:
ls ~/opt/anaconda3/envs/abenv_01/lib/python3.9/site-packages/medchem/data/
I used pip to install the package
running the shared python code returns
/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/site-packages/medchem/data
`['grammar.lark',
'nibr.csv',
'medchem_rule_list.csv',
'complexity',
'graph.csv',
'queries',
'bredt.csv',
'common_alerts_collection.csv',
'smarts_bank.csv',
'charge_assigner',
'chemical_groups.csv']
Oh, that's strange the required file is there ("medchem_rule_list.csv"
), so it's strange that it's returning None.
Do you know if the following code returns the file ?
from medchem.utils import loader
loader.get_data_path("medchem_rule_list.csv")
I will try to replicate with your exact version of python.
thank you!
same issue arises
>>> from medchem.utils import loader
>>> loader.get_data_path("medchem_rule_list.csv")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/site-packages/medchem/utils/loader.py", line 17, in get_data_path
path = importlib.resources.files(module).joinpath(filename)
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/importlib/resources.py", line 147, in files
return _common.from_package(_get_package(package))
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/importlib/_common.py", line 14, in from_package
return fallback_resources(package.__spec__)
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/importlib/_common.py", line 18, in fallback_resources
package_directory = pathlib.Path(spec.origin).parent
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/pathlib.py", line 1082, in __new__
self = cls._from_parts(args, init=False)
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/pathlib.py", line 707, in _from_parts
drv, root, parts = self._parse_args(args)
File "/Users/ec_lab/opt/anaconda3/envs/abenv_03/lib/python3.9/pathlib.py", line 691, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
just checked on my end and it works for me with python=3.10
Yes, it's importlib.resources
. On python 3.9 it does not recognize module without __init__.py
for data serving (which has been adopted in python since 3.3).
Using python >=3.10 should work.
I am also pushing a fix to cover that edge case.
Hello!
Great package and very excited to use it.
However I'm running into an issue following the tutorial Filtering with rules. These two lines raise an error.
Code to reproduce
raises
TypeError: expected str, bytes or os.PathLike object, not NoneType
Configuration:
Full error message