갈루아의 반서재

pip install -U setuptools fails in fresh conda environment


setuptools 를 업그레이드하는 경우 Cannot remove entries from nonexistent file 에러가 발생하는 경우에는 다음과 같이 처리한다.


1
2
3
4
5
6
7
8
9
10
11
# pip install -U pip setuptools
Requirement already up-to-date: pip in /root/anaconda/envs/envalicia/lib/python3.5/site-packages
Collecting setuptools
  Using cached setuptools-35.0.2-py2.py3-none-any.whl
Requirement already up-to-date: packaging>=16.8 in /root/anaconda/envs/envalicia/lib/python3.5/site-packages (from setuptools)
Requirement already up-to-date: appdirs>=1.4.0 in /root/anaconda/envs/envalicia/lib/python3.5/site-packages (from setuptools)
Requirement already up-to-date: six>=1.6.0 in /root/anaconda/envs/envalicia/lib/python3.5/site-packages (from setuptools)
Requirement already up-to-date: pyparsing in /root/anaconda/envs/envalicia/lib/python3.5/site-packages (from packaging>=16.8->setuptools)
Installing collected packages: setuptools
  Found existing installation: setuptools 27.2.0
Cannot remove entries from nonexistent file /root/anaconda/envs/envalicia/lib/python3.5/site-packages/easy-install.pth
cs


위의 에러 메시지는 site-package 에 easy-install.pth 가 없다는 것으로 정확한 표현이다. 그러니깐 pip 가 이전 setuptools 패키지를 제거하려고 할 때 발생한다.

/pip/req/req_uninstall.py

1
2
3
4
5
6
7
8
9
class UninstallPthEntries(object):
    def __init__(self, pth_file):
        if not os.path.isfile(pth_file):
            raise UninstallationError(
                "Cannot remove entries from nonexistent file %s" % pth_file
            )
        self.file = pth_file
        self.entries = set()
        self._saved_lines = None
cs


해결책은 2가지이다. 하나는 --ignore-installed 옵션을 붙여서 업그레이드 한다.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
# pip install -U pip setuptools --ignore-installed
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached setuptools-35.0.2-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from setuptools)
  Using cached appdirs-1.4.3-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools)
  Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Installing collected packages: pip, six, pyparsing, packaging, appdirs, setuptools
Successfully installed appdirs-1.4.3 packaging-16.8 pip-9.0.1 pyparsing-2.2.0 setuptools-35.0.2 six-1.10.0
cs


또 다른 방법으로는 ez_setup.py 를 다운로드하여 실행한다. 이 경우 없는 pth 파일을 생성한다.