1

关于“为什么 pip 会引发 SyntaxError?”的问题似乎有几十个。所有的答案都是“从系统 shell 运行它,而不是 python shell”。这不是这些问题之一。我使用 pip 安装了 django-import-export,并在输出中得到了一些 SyntaxErrors。该模块本身似乎工作正常,只是想知道 SystaxErrors 是怎么回事。

这是整个输出:

c:\Dev\Website>pip install django-import-export
Downloading/unpacking django-import-export
  Running setup.py (path:c:\users\username\appdata\local\temp\pip_build_username\django-import-export\setup.py) egg_info for pac
kage django-import-export

Downloading/unpacking tablib (from django-import-export)
Downloading/unpacking diff-match-patch (from django-import-export)
  Running setup.py (path:c:\users\username\appdata\local\temp\pip_build_username\diff-match-patch\setup.py) egg_info for package
 diff-match-patch

Installing collected packages: django-import-export, tablib, diff-match-patch
  Running setup.py install for django-import-export

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\__init__.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\__init__.py", line 855
    print("mem: %s, base: %d, len: %d" % (type(self.mem), self.base, self.stream_len), file=self.logfile)
                                                                                           ^
SyntaxError: invalid syntax

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\biffh.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\biffh.py", line 386
    print(header, file=f)
                      ^
SyntaxError: invalid syntax

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\compdoc.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\compdoc.py", line 89
    print("\nCompDoc format: version=0x%04x revision=0x%04x" % (version, revision), file=logfile)
                                                                                        ^
SyntaxError: invalid syntax

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\formatting.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\formatting.py", line 589
    print("%2d: %r -> %r" % (i, old_rgb, new_rgb), file=book.logfile)
                                                       ^
SyntaxError: invalid syntax

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\formula.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\formula.py", line 794
    if verbose: print("tIsect pre", stack, file=bk.logfile)
                                               ^
SyntaxError: invalid syntax

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\sheet.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlrd3\sheet.py", line 466
    print("put_cell", rowx, colx, file=self.logfile)
                                      ^
SyntaxError: invalid syntax

Compiling c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlwt3\antlr.py ...
  File "c:\users\username\appdata\local\temp\pip_build_username\tablib\tablib\packages\xlwt3\antlr.py", line 1946
    print(fmt % (line,col,text), file=sys.stderr)
                                     ^
SyntaxError: invalid syntax

  Running setup.py install for diff-match-patch

Successfully installed django-import-export tablib diff-match-patch
Cleaning up...

c:\Dev\Website>python -c "import import_export; print(import_export)"
<module 'import_export' from 'C:\Python27\lib\site-packages\import_export\__init__.pyc'>
4

0 回答 0