Python pip install 返回无效语法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47632891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip install returning invalid syntax
提问by zgg6a
I've just installed python 3.6 which comes with pip
我刚刚安装了 pip 附带的 python 3.6
However, in Windows command prompt, when I do: 'pip install bs4' it returns 'SyntaxError: invalid syntax' under the install word.
但是,在 Windows 命令提示符下,当我执行以下操作时: 'pip install bs4' 它在安装字下返回 'SyntaxError: invalid syntax'。
Typing 'python' returns the version, which means it is installed correctly. What could be the problem?
键入“python”返回版本,这意味着它已正确安装。可能是什么问题呢?
回答by Tiago_nes
try this.
尝试这个。
python -m pip ...
-m module-name Searches sys.path for the named module and runs the corresponding .py file as a script.
-m module-name 在 sys.path 中搜索命名模块并运行相应的 .py 文件作为脚本。
Sometimes the OS can't find pip so python
or py
-m
may solve the problem because it is python itself searching for pip
.
有时OS找不到PIP所以python
还是py
-m
因为它是Python本身寻找可能解决问题pip
。
回答by Dipak
You need to be in the specific folder where pip.exe exists, then do the following steps:
您需要在pip.exe所在的特定文件夹中,然后执行以下步骤:
- open cmd.exe
- write the following command:
- 打开cmd.exe
- 编写以下命令:
cd "The path to the python folder"
or in my case, i wrote
或者就我而言,我写道
cd C:\Users\username\AppData\Local\Programs\Python\Python37-32\Scripts
- then write the following command
- 然后编写以下命令
pip install *anypackage*
回答by vidyasagar mulge
Don't enter in the python shall, Install in the command directory.
不要在python中输入,安装在命令目录下。
Not inside the python pip cannot be installed inside the python.
不在python里面的pip不能安装在python里面。
Even in the version 3.+ you don't have to write the python 3 instead just python.
即使在版本 3.+ 中,您也不必编写 python 3,而只需编写 python。
which looks like
看起来像
python -m pip install --upgrade pip
and then install others
然后安装其他
python -m pip install jupyter
回答by David Ordman
Try running cmd as administrator (in the menu that pops up after right-clicking) and/or entering "pip" alone and then
尝试以管理员身份运行 cmd(在右键单击后弹出的菜单中)和/或单独输入“pip”然后
回答by Sridevi Amit B
In windows, you have to run pip install command from( python path)/ scripts path in cmd prompt
在 Windows 中,您必须在 cmd 提示符下从(python 路径)/脚本路径运行 pip install 命令
C:/python27/scripts
C:/python27/scripts
pip install pandas
pip 安装熊猫
回答by owenhe
I use Enthought Canopy for my python, at first I used "pip install --upgrade pip", it showed a syntax error like yours, then I added a "!" in front of the pip, then it finally worked.
我为我的 python 使用了 Enthought Canopy,起初我使用了“pip install --upgrade pip”,它显示了一个像你一样的语法错误,然后我添加了一个“!” 在 pip 前面,然后它终于起作用了。
回答by Roman Shubenko
回答by Kelly Le
You can also go into the directory where you have your pip.exe or pip3.exe located. For me it was on my D drive so here is what I did:
您也可以进入 pip.exe 或 pip3.exe 所在的目录。对我来说,它在我的 D 驱动器上,所以这是我所做的:
D:\>cd python
D:\python>cd Scripts
D:\python\Scripts>pip3.exe install tweepy
Hope it helps
希望能帮助到你
回答by shubhamsarohi
Chances are you are in the Python interpreter. Happens sometimes if you give this (Python) command in cmd.exe just to check the version of Python and you so happen to forget to come out.
您很有可能在 Python 解释器中。如果您在 cmd.exe 中提供此 (Python) 命令只是为了检查 Python 的版本,而您恰好忘记出来,有时会发生这种情况。
Try this command
试试这个命令
exit()
pip install xyz
回答by Elliot
You need to run pip install in the command prompt, outside from a python interpreter ! Try to exit python and re try :)
您需要在命令提示符下运行 pip install ,在 python 解释器之外!尝试退出python并重新尝试:)