每当我在Mac终端中执行pip3冻结或任何pip3命令时,都会引发语法错误

时间:2018-09-20 22:42:58

标签: python pip

通常,pip3正常工作,但是在使用pip安装张量流之后,由于某种原因pip不再起作用。例如,我做了pip freeze来获得我的包裹,但它出现了此错误。

    Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
    from pip._internal import cmdoptions
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
    from pip._internal.index import (
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/index.py", line 24, in <module>
    from pip._internal.download import HAS_TLS, is_url, path_to_url, url_to_path
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 39, in <module>
    from pip._internal.utils.logging import indent_log
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/utils/logging.py", line 9, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 21, in <module>
    from pip._vendor import pkg_resources
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3095, in <module>
    @_call_aside
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3079, in _call_aside
    f(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3123, in _initialize_master_working_set
    for dist in working_set
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3123, in <genexpr>
    for dist in working_set
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2633, in activate
    declare_namespace(pkg)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2170, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2105, in _handle_ns
    loader.load_module(packageName)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pygoogle/google.py", line 118
    %(__credits__)s""" % globals()
                     ^
SyntaxError: invalid syntax

但是当我执行pip2 freeze时,它的工作完全正常。

我不确定是否是tenserflow引起的,但是在我安装它之后它开始发生。 我有一个Mac OS Sierra 10.13.4,并在终端上执行了命令。我正在使用python 3.6.6。有没有什么办法解决这一问题?我还尝试卸载张量流。

1 个答案:

答案 0 :(得分:0)

问题的原因似乎是一个python 2.7模块以某种方式安装到python 3.6文件夹中。有罪模块是pygoogle。卸载可能会起作用。参见:

https://www.pythonanywhere.com/forums/topic/12390/

Tensorflow SyntaxError with python 3.5.2