Hi. I'm running into trouble with module mappings ...
# general
f
Hi. I'm running into trouble with module mappings for tkinter package. tkinter is installed with pip install tk, so i've added it to the module mapping. However it's still not being included in the environment. I have checked that the dependencies look correct:
Copy code
(base3.10) matt@DGX-2:~/mlcore/libs$ pants dependencies mldb/tests/conftest.py 
3rdparty/python:default#pytest
3rdparty/python:default#requests
3rdparty/python:default#tk
And i have added the module mapping into the python_requirements target:
Copy code
module_mapping={"ffmpeg-python": ["ffmpeg"], "GPUtil": ["GPUtil"], "pillow": ["PIL"], "tk":["tkinter"]}
And tk is included in the requirements.txt. I'm not sure what the next debug step is. I can see tk in the lockfile but can't tell which part os pants is not including tk in the environment when i run tests. Are there anyways to see what pants will include in an environment? (other than dependencies goal?)
1
c
providing the exact error messages you get may be helpful, in case there are details you’ve overlooked.
f
Sure, here you go:
Copy code
(base3.10) matt@DGX-2:~/mlcore/libs$ pants test mldb/::
14:51:47.39 [INFO] Canceled: Building 23 requirements for requirements.pex from the 3rdparty/python/default.lock resolve: boto3, jsonschema==3.2.0, numpy~=1.24.4, nvidia-cublas-cu12, nvidia-cuda-cupti-cu12, nvidia-cuda-nvrtc-cu12... (294 characters truncated)
14:53:00.37 [INFO] Completed: Building 23 requirements for requirements.pex from the 3rdparty/python/default.lock resolve: boto3, jsonschema==3.2.0, numpy~=1.24.4, nvidia-cublas-cu12, nvidia-cuda-cupti-cu12, nvidia-cuda-nvrtc-cu12... (294 characters truncated)
14:53:02.27 [INFO] Completed: Building 24 requirements for requirements.pex from the 3rdparty/python/default.lock resolve: boto3, jsonschema==3.2.0, numpy~=1.24.4, nvidia-cublas-cu12, nvidia-cuda-cupti-cu12, nvidia-cuda-nvrtc-cu12... (321 characters truncated)
14:53:02.99 [WARN] Failed to generate JUnit XML data for libs/mldb/tests/dataset_utils/timestamp_projects/test_timestamp_video.py:tests.
14:53:02.99 [ERROR] Completed: Run Pytest - libs/mldb/tests/dataset_utils/timestamp_projects/test_timestamp_video.py:tests - failed (exit code 4).
ImportError while loading conftest '/tmp/pants-sandbox-HqwzAD/libs/mldb/tests/conftest.py'.
libs/mldb/tests/conftest.py:12: in <module>
    import tkinter
E   ModuleNotFoundError: No module named 'tkinter'
It repeats the no module named 'tkinter' for each test (as the impor error is in the conftest.py) and marks all the tests as failed.
👍 1
c
just curious, does it make any difference if you add a tkinter import in one of the regular sources? (thinking in case the conftest.py file is not part of the source pool properly when looking at which requirements are needed)
f
yeah i tried that and it gets the same error for those files as well. The dependencies of the individual files also point to tk when i use --transitive.
c
well,
pip install tk
would give you this package, right? https://pypi.org/project/tk Which has these files, which seems to be not what you want..
Copy code
❯ tar -tzf ~/Downloads/tk-0.1.0-py3-none-any.whl
tk/__init__.py
tk/structure/Tensor.py
tk/structure/TensorMap.py
tk/structure/__init__.py
tk-0.1.0.dist-info/LICENSE
tk-0.1.0.dist-info/METADATA
tk-0.1.0.dist-info/WHEEL
tk-0.1.0.dist-info/top_level.txt
tk-0.1.0.dist-info/RECORD
you sure you didn’t mean to be using tkinter from the python std lib? https://docs.python.org/3.11/library/tkinter.html#module-tkinter so you shouldn’t need to install it at all…
perhaps pants should warn if you add a module mapping for an entry already known as being a default “unknown” (meaning it’s provided by default)
but that leaves the question why you can’t import tkinter… what Python installation is this? Guess if you’re using a system python, that you need to install the system package that provides the tkinter part of the python setup separately.
for ubuntu, this is likely something like:
Copy code
apt-get install python-tk
marking this as answered (not a pants issue) 😉
f
🤦 thanks, i should have seen that. I assumed i had misconfigured pants. 👍
🙈 1
👍 1