NameError: name '__version__' is not defined
Loris Bennett
loris.bennett at fu-berlin.de
Fri Oct 27 03:29:16 EDT 2023
Hi,
I have two applications. One uses the system version of Python, which
is 3.6.8, whereas the other uses Python 3.10.8 installed in a non-system
path. For both applications I am using poetry with a pyproject.toml
file which contains the version information and __init__.py at the root
which contains
try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata
__version__ = importlib_metadata.version(__name__)
For the application with the system Python this mechanism works, but for
the non-system Python I get the error:
NameError: name '__version__' is not defined
For the 3.6 application I have
PYTHONPATH=/nfs/local/lib/python3.6/site-packages
PYTHONUSERBASE=/nfs/local
PYTHON_VERSION=3.6
PYTHON_VIRTUALENV=
and for the 3.10 application I have
PYTHONPATH=/nfs/easybuild/software/Python/3.10.8-GCCcore-12.2.0/easybuild/python:/nfs/local/lib/python3.10/site-packages
PYTHONUSERBASE=/nfs/local
PYTHON_VERSION=3.10
PYTHON_VIRTUALENV=
The applications are installed in /nfs/local/lib/python3.6/site-packages
and /nfs/local/lib/python3.10/site-packages, respectively.
Can anyone see where this is going wrong? I thought it should be
enough that the packages with the metadata is available via PYTHONPATH,
but this seems not to be sufficient. So I must be overseeing something.
Cheers,
Loris
--
This signature is currently under constuction.
More information about the Python-list
mailing list