在Azure WebApp中使用PIP

2024-05-10 04:31:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Azure还不太熟悉,我正在尝试让Django WebApp启动并运行。我用FTP上传了文件,但是Azure不运行我的requirements.txt

所以我搜索了一下,发现可以用pip安装requirements.txt

回到蔚蓝,PIP似乎不起作用。无论是在控制台,库杜命令或库杜电源地狱。Python确实有效。
当我试图通过Python安装PIP时,它首先说已经安装了一个旧版本。当Python尝试升级PIP时,它无法访问需要编辑的文件夹。

我在想我怎样才能在蔚蓝中使用PIP。
(如果你知道安装requirements.txt的另一种方法,请告诉我,因为这是我最初实现这一点的方式。)


Tags: pip文件django方法命令txt文件夹编辑
3条回答

根据我的理解,我认为您希望为Python创建一个虚拟环境,并使用Django WebApp的requirement.txt进行一些包安装,但遇到了一些问题。

对于Azure WebApp上的Django,我建议从Azure旧门户上的库创建一个WebApp预安装的Django。

但是,根据Azure官方文档,您也不能使用pip安装一些包,请参阅下面的这些案例。

Some packages may not install using pip when run on Azure. It may simply be that the package is not available on the Python Package Index. It could be that a compiler is required (a compiler is not available on the machine running the web app in Azure App Service).

但是您可以参考官方的疑难解答文档来处理这个问题,请参见https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-django-app/#troubleshooting---package-installation

您将无法升级Django webapp的pip,因为您将无法访问系统文件。

相反,您可以升级virtualenv的pip,这可以通过在install requirements.txt命令之前在deploy.cmd文件中添加一行来完成。

env\scripts\python -m pip install --upgrade pip

记住不要用pip(env/scripts/pip)升级pip,否则它将卸载全局pip。

你试过用简易安装升级pip吗?以下是在Azure kudu控制台中为我工作的:

python-m easy_install--升级--用户pip

相关问题 更多 >