日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MacOS安装pip失败,提示:SyntaxError: invalid syntax

發(fā)布時間:2023/12/3 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MacOS安装pip失败,提示:SyntaxError: invalid syntax 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

使用命令 easy_install 安裝 pip

使用命令 sudo easy_install pip 安裝 pip,結果失敗了,執(zhí)行命令的信息如下:

? ~ sudo easy_install pip Password: Searching for pip Reading https://pypi.org/simple/pip/ Downloading https://files.pythonhosted.org/packages/da/f6/c83229dcc3635cdeb51874184241a9508ada15d8baa337a41093fab58011/pip-21.3.1.tar.gz#sha256=fd11ba3d0fdb4c07fbc5ecbba0b1b719809420f25038f8ee3cd913d3faa3033a Best match: pip 21.3.1 Processing pip-21.3.1.tar.gz Writing /tmp/easy_install-8XXfb1/pip-21.3.1/setup.cfg Running pip-21.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-8XXfb1/pip-21.3.1/egg-dist-tmp-5cqtMF Traceback (most recent call last): # 省略100行 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 44, in _execfilecode = compile(script, filename, 'exec')File "/tmp/easy_install-8XXfb1/pip-21.3.1/setup.py", line 7def read(rel_path: str) -> str:^ SyntaxError: invalid syntax

解決方案

下載腳本文件 get-pip.py:

curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py

接著使用命令 python3 執(zhí)行腳本文件 get-pip.py:

sudo python3 get-pip.py

就這樣完成安裝了。

執(zhí)行命令的過程信息如下所示:

? ~ curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed 100 2108k 100 2108k 0 0 2571k 0 --:--:-- --:--:-- --:--:-- 2568k ? ~ sudo python3 get-pip.py Password: WARNING: The directory '/Users/liaowenxiong/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Collecting pipDownloading pip-21.3.1-py3-none-any.whl (1.7 MB)|████████████████████████████████| 1.7 MB 1.0 MB/s Installing collected packages: pipAttempting uninstall: pipFound existing installation: pip 21.2.4Uninstalling pip-21.2.4:Successfully uninstalled pip-21.2.4 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Successfully installed pip-21.3.1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv ? ~ pip --version pip 21.3.1 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

更簡單的執(zhí)行命令如下:

curl https://bootstrap.pypa.io/get-pip.py | python3

卸載 pip

sudo pip uninstall pip

總結

以上是生活随笔為你收集整理的MacOS安装pip失败,提示:SyntaxError: invalid syntax的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。