Pip 安装导致错误。我可以通过 pdb 调试它吗?

Pip install causes error. Can I debug it via pdb?

Ubuntu 16.04
Python 3.5.2

在 virtualenv 中,如果我 运行 python,我得到 Python 3.5.2.

问题是:

(photoarchive) admin@simple_project:~/venv/photoarchive/lib/python3.5/encodings$ pip install django-crequest
Collecting django-crequest
  Using cached django-crequest-2016.3.16.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-2qlcw5ux/django-crequest/setup.py", line 9, in <module>
        license=open('LICENSE').read(),
      File "/home/admin/venv/photoarchive/lib/python3.5/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 204: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2qlcw5ux/django-crequest/

好吧,pip install 毁了一切。顺便说一下,没有 virtualenv 这个包是通过 pip 安装的。

我被困住了,不知道该如何应对。

我唯一能想到的就是停在ascii.py中的第26行。 这似乎可以通过 pdb 实现。我将对其进行编辑并在其中添加 pdb.set_trace() 。然后保存文件。

这是个好主意吗?另一个问题:是否可以不编辑文件?

这看起来确实很奇怪。这可能是由于下载损坏(正在缓存)。为确保重新下载,请执行

pip install --no-cache-dir django-crequest

如果出现同样的错误,请尝试下载源代码并编辑setup.py:

mkdir tmp
pip download django-crequest --dest=./tmp
cd tmp
tar xfz django-crequest-2016.3.16.tar.gz
cd django-crequest-2016.3.16
sed -i '9 s/^/#/' setup.py  # comments out line 9 in setup.py

现在通过编辑的setup.py进行安装:

python setup.py install