Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError when importing bioscrape from inside bioscrape directory. #21

Open
ayush9pandey opened this issue Apr 21, 2020 · 5 comments · Fixed by #165
Open
Assignees
Labels
Bioscrape Core Issues pertaining to core bioscrape functionality bug Something isn't working

Comments

@ayush9pandey
Copy link
Collaborator

MWE to produce this error:

>> cd bioscrape/
>> python
>> import bioscrape
'Module not found error bioscrape.random not found'
(this is an error in __init__.py)
@ayush9pandey ayush9pandey self-assigned this Apr 21, 2020
@ayush9pandey ayush9pandey added bug Something isn't working Bioscrape Core Issues pertaining to core bioscrape functionality labels Apr 21, 2020
@ayush9pandey
Copy link
Collaborator Author

ayush9pandey commented Apr 22, 2020

As this error only occurs when importing from the root directory (which no one should do, ideally), but people end up creating their files in this root directory sometimes and end up with this error. If this was a pure python package, this error wouldn't exist but bioscrape import statements work from the compiled version only (i.e. the installed package in sites-packages).

What could be a good way to solve this issue? One way is to simply issue a warning or an error if someone tries to import bioscrape from the root directory (they should not be doing this). The other way is to some how force all the imports to look at sites-packages by default.

Any ideas @sclamons @WilliamIX ?

@WilliamIX
Copy link
Collaborator

@ayush9pandey I think an error or warning would be fine, maybe in init of the package?

@ayush9pandey
Copy link
Collaborator Author

ayush9pandey commented Jun 15, 2021

Yes, but how do we detect that the user is inside the directory? There must be a way tho, I didn't look closely for a solution. But if it can be done, cleanly we should do it

@ayush9pandey
Copy link
Collaborator Author

Adding the package to src/ will solve this issue. Most other python packages do this, and it is probably the correct packaging practice.

@ayush9pandey
Copy link
Collaborator Author

Fixed in documentation #165

@ayush9pandey ayush9pandey linked a pull request Feb 21, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bioscrape Core Issues pertaining to core bioscrape functionality bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants