~Hi team, a question on third party dependencies, ...
# general
w
Hi team, a question on third party dependencies, let us say in the requirement.txt, there is
x.y==1.0
. In a python script, there is
from x.y import z
. It seems that Pants will complain
ModuleNotFoundError: No module named 'x'
. Is it expected? and how to solve it?
h
Have you seen the module_mapping argument?
I've had to use this a few times
Pants comes with some built-in defaults, but it doesn't catch everything. Here's a taste of what we've had to do in our repo
Copy code
python_requirements(
    name="reqs",
    module_mapping={
        "pyzmq": ["zmq"],
        "ipython": ["IPython"],
        "pyserial": ["serial"],
        "pyserial-asyncio": ["serial_asyncio"],
        "python-can": ["can"]
    },
)
The
x.y==1.0
is confusing to me, though. Don't think I've ever seen dot notation in package names. Are you able to
pip install x.y
or only
pip install x
?
h
pants itself uses dot notation in the distribution package name! https://pypi.org/project/pantsbuild.pants/
😮 1
But the top-level import package is just
pants
What is the specific
x.y
in the example?
Because you need to be sure that you're using the right distribution name in requirements.txt and the right import name in
import
statements, and they may not be the same
👍 1
h
w
Hi @happy-kitchen-89482 thanks for getting back. the x.y is equal to an internal lib we had
I look at that page. I am sure which section applies to my case : (
thanks guys. I found that the issue of not finding the module is due to another issue. I will post another thread.