[英]sudo -H python2 -m pip install -U pip # Update pip
I am new in working with a kinect.我是使用 kinect 的新手。 I am using a Mac OS Sierra 10.12.6.
我使用的是 Mac OS Sierra 10.12.6。 Wheneve I try to update python with :
当我尝试使用以下命令更新 python 时:
sudo -H python2 -m pip install -U pip # Update pip
I got this error:我收到此错误:
File "<stdin>", line 1
sudo -H python2 -m pip install -U pip # Update pip
^
SyntaxError: invalid syntax
How do we fix it?我们如何修复它?
What you are doing is running a console command inside python shell,你正在做的是在 python shell 中运行一个控制台命令,
press ctrl+D
to exit out of python shell and then try executing the pip upgrade command按
ctrl+D
退出 python shell,然后尝试执行 pip upgrade 命令
to upgrade pip using pip itself使用 pip 本身升级 pip
pip install --upgrade pip # run in console/terminal
to upgrade pip using python使用python升级pip
python -m pip install --upgrade pip # run in console/terminal
You can avoid the need for sudo
if you're just a single user on your machine.如果您只是机器上的单个用户,则可以避免使用
sudo
。 This also avoids potentially messing around with the system-wide installation.这也避免了对系统范围安装的潜在干扰。
Use用
python2.7 -m pip install pip --upgrade --user
The --user
option will install the updated pip
package just for your user account. --user
选项将为您的用户帐户安装更新的pip
包。 Everytime you use python2.7
, it will use the newer pip
package.每次使用
python2.7
,它都会使用较新的pip
包。
System routines will not see the newer pip
package, nor be bothered by it.系统例程不会看到较新的
pip
包,也不会被它打扰。
python2.7
is needed, because python2
doesn't really exist: it's either python
or python2.7
for version 2. Python version 3 doesn't (apparently) exist by default on macOS.需要
python2.7
,因为python2
并不真正存在:对于版本 2,它是python
或python2.7
。默认情况下,macOS 上不存在(显然)Python 版本 3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.