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

NameError when installing pylint in a Docker image #2538

Closed
ethanchewy opened this issue Oct 8, 2018 · 3 comments
Closed

NameError when installing pylint in a Docker image #2538

ethanchewy opened this issue Oct 8, 2018 · 3 comments

Comments

@ethanchewy
Copy link

For some reason, I run into this issue when trying to install pylint versions > 2.0 in Docker (earlier version work).

Steps to reproduce

  1. In my Dockerfile, I write:
FROM node:argon

RUN ["adduser",  "--home",  "/usr/src/app", "--system", "sandboxuser"]
RUN ["chown", "-R", "sandboxuser", "/usr/src/app"]
RUN ["chmod", "-R", "u+rwx", "/usr/src/app"]

COPY ./shared /usr/src/app
RUN cd /usr/src/app && npm install

COPY start.sh /
RUN chmod 755 /start.sh

RUN apt-get update

# Install python 3
RUN apt-get update && apt-get install -y python3 python3-pip

RUN pip3 install pylint==1.9

CMD ["/start.sh"]
  1. I build said Docker image:
    docker build -t testing .

Current behavior

...
Step 11/12 : RUN pip3 install pylint
 ---> Running in 79ce94f5a7e4
Downloading/unpacking pylint
Downloading/unpacking astroid>=2.0.0 (from pylint)
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2595, in _dep_map
    return self.__dep_map
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2457, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 290, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1266, in prepare_files
    req_to_install.extras):
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2401, in requires
    dm = self._dep_map
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2597, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2630, in _compute_dependencies
    common = frozenset(reqs_for_extra(None))
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2627, in reqs_for_extra
    if req.marker_fn(override={'extra':extra}):
  File "/usr/lib/python3/dist-packages/_markerlib/markers.py", line 113, in marker_fn
    return eval(compiled_marker, environment)
  File "<environment marker>", line 1, in <module>
NameError: name 'implementation_name' is not defined

Storing debug log for failure in /root/.pip/pip.log
The command '/bin/sh -c pip3 install pylint' returned a non-zero code: 2

Expected behavior

Step 11/12 : RUN pip3 install pylint
 ---> Running in 79ce94f5a7e4
Downloading/unpacking pylint
Downloading/unpacking astroid>=2.0.0 (from pylint)
...
Successfully installed pylint
...

Not sure if this has to do with me. When I change it to an earlier version in my Dockerfile, it works:
RUN pip3 install pylint==1.9

Not exactly sure why...

pylint --version output

@ethanchewy
Copy link
Author

Related issue for reference: #2291

@PCManticore
Copy link
Contributor

@ethanchewy This is caused by our use of environment markers in astroid: https://github.com/PyCQA/astroid/blob/master/astroid/__pkginfo__.py#L33. I managed to reproduce this error using your Dockerfile, thanks for providing that! The problem is that your container uses an old version of setuptools that doesn't know how to handle environment markers correctly, if you do a pip3 install setuptools -U before installing pylint, that should solve this problem for you.

@damnko
Copy link

damnko commented May 23, 2020

Hi @PCManticore , I'm encountering the same issue using Python 3.5.2, while trying to install pylint==2.4.2. Running pip3 install setuptools -U doesn't solve the issue, do you have any suggestion on next steps I could try? Thanks

Edit: Also running simply pip install pylint fails with the same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants