You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just tried to install HAPI into a new virtual environment and it failed with the message:
ModuleNotFoundError: No module named 'numpy'
This is because Numpy is not declared in setup.py as a dependency.
You can use the install_requires keyword argument to include Numpy as an explicit dependency:
setup(
name='hitran-api',
version=HAPI_VERSION,
packages=['hapi',],
install_requires=["numpy",], # This is missing. Better specify a version, e.g. "numpy>=1.20" or whatever HAPI needslicense='MIT',
)
The next problem is that setup.py imports HAPI_VERSION and HAPI_HISTORY form hapi.hapi.
This leads to setup.py trying to import Numpy, which then fails, although Numpy is now a declared dependency.
I solved this problem by moving the declarations of HAPI_VERSION and HAPI_HISTORY into a file _version.py in the root of the repository and then did
from_versionimportHAPI_VERSION, HAPI_HISTORY
in setup.py.
If you want to keep these declarations inside the hapi folder, I guess you would need to remove
from .hapiimport*
from __init__.py, because this triggers the import of Numpy.
This problem seemed to be undetected for quite a while, I guess because most people have Numpy installed.
However, if your want to use a dedicated environment for your project (like I always do), Numpy will not be available by default.
Best regards
Nils
The text was updated successfully, but these errors were encountered:
Oh, moving HAPI_VERSION and HAPI_HISTORY into the root folder does not work, because it is needed in the hapi module itself. The dirty and not well maintainable hack would be to just have a copy of _version.py in the hapi folder, but I guess using __all__ is the better solution. You seem to have used __all__ previously, it is commented out in __init__.py. Was there a problem?
Hi,
thanks for developing HAPI 😄
I just tried to install HAPI into a new virtual environment and it failed with the message:
This is because Numpy is not declared in
setup.py
as a dependency.You can use the
install_requires
keyword argument to include Numpy as an explicit dependency:The next problem is that
setup.py
importsHAPI_VERSION
andHAPI_HISTORY
formhapi.hapi
.This leads to
setup.py
trying to import Numpy, which then fails, although Numpy is now a declared dependency.I solved this problem by moving the declarations of
HAPI_VERSION
andHAPI_HISTORY
into a file_version.py
in the root of the repository and then didin
setup.py
.If you want to keep these declarations inside the hapi folder, I guess you would need to remove
from
__init__.py
, because this triggers the import of Numpy.You should be able to do this if you instead declare the exported functions with the
__all__
variable, like described here:https://docs.python.org/3/tutorial/modules.html#importing-from-a-package
This problem seemed to be undetected for quite a while, I guess because most people have Numpy installed.
However, if your want to use a dedicated environment for your project (like I always do), Numpy will not be available by default.
Best regards
Nils
The text was updated successfully, but these errors were encountered: