如何在Windows PowerShell中使用pip安装软件包 [英] How to install packages with pip in Windows PowerShell

查看:1023
本文介绍了如何在Windows PowerShell中使用pip安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 8计算机上使用Python 2.7.9.

I am using Python 2.7.9 on a Windows 8 computer.

我尝试在键入python后在Windows PowerShell中键入pip install lxml来安装lxml,但是出现以下错误:SyntaxError: invalid syntax

I tried to install lxml by typing pip install lxmlin Windows PowerShell after typing python, but I get the following error: SyntaxError: invalid syntax

我尝试通过使用以下教程

I tried installing pip by using the following tutorial http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/ only to later realize that I already had pip.exe, pip2.7.exe and pip2.exe installed when I first installed Python. They are located in the C:\Python27\Scripts directory.

但是,如果我尝试类似pip help的操作,则会收到无效的语法错误.

Yet, if I try something like pip help I will get an invalid syntax error.

是否必须重新安装pip或如何使其工作才能安装lxml库.

Do I have to reinstall pip or how do I get it to work in order to install the lxml library.

感谢您提供的任何帮助.

Thank you for any help you can provide.

推荐答案

我遇到了同样的问题.您需要设置PATH环境变量,以便系统识别命令"pip".

I had the same problem. You need to set the PATH environment variable, so that the system recognizes the command "pip".

如果[在PowerShell中]输入easy_install或pip不起作用,则表示Scripts文件夹不在您的路径中.在这种情况下,请运行下一个命令(请注意,此命令只能运行一次,否则PATH会越来越长). 确保使用正确的Python安装位置替换c:\ Python33 \ Scripts:

If typing easy_install or pip [in PowerShell] doesn’t work, it means the Scripts folder is not in your path. Run the next command in that case (Note that this command must be run only once or your PATH will get longer and longer). Make sure to replace c:\Python33\Scripts with the correct location of your Python installation:

setx PATH "%PATH%;C:\Python33\Scripts"

运行此命令后,关闭并重新打开PowerShell.

Close and reopen PowerShell after running this command.

来源: http://arunrocks.com/guide -to-install-python-or-pip-on-windows/

这篇关于如何在Windows PowerShell中使用pip安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆