Closed domna closed 9 months ago
I couldn't reproduce this. I don't think it should look for folders first anyways. That's odd.
Do you get this error on your machine as well, @domna?
Edit: It only results in an error when we cd out of the cloned repo folder. That is we do the following steps:
git clone --recurse-submodules https://github.com/FAIRmat-NFDI/pynxtools.git
cd pynxtools
pip install -e .
cd ..
Everywhere else it works fine.
I did reproduce this in the mpesjupyter container. Maybe they have .
in the pythonpath by default?
I'll try locally again
Edit: Can also reproduce locally
This is, unfortunately, expected behavior. The Python import mechanism will first look for a folder with the package name in the current working directory. If it finds a folder named pynxtools
, it will try to import from there. In this case we have the cloned repo folder with the same name, pynxtools
. Python tries to import from this folder but the code resides in pynxtools/pynxtools
.
If you are working in a directory containing the repo folder, pynxtools
, rename this repo folder to pynxtools2
so your current directory looks like this:
.
├── pynxtools2 # Renamed repo folder
│ ├── pynxtools # Actual module code is in here
│ ├── tests
│ └── ...
└── my_code_imports_pynxtools.py
Then reinstall the package and your import will work.
git clone --recurse-submodules https://github.com/FAIRmat-NFDI/pynxtools.git
cd pynxtools
pip install -e .
cd ..
I would suggest as solution to change the dev-install instructions to clone into a different folder name, e.g.
git clone --recurse-submodules https://github.com/FAIRmat-NFDI/pynxtools.git pynxtools_dev
If I do
and in the top directory do
I get an import error because python tries to resolve from the folder. This happens if any folder named
pynxtools
is present. The thing is that this also happens if dataconverter is used in this folder. Maybe we should switch to relative imports because it should avoid this problem? Otherwise, we could just write a note about this in the README. @sherjeelshabih What do you think?This was reported by @rettigl