如何在离线计算机上安装 fastapi

huangapple go评论89阅读模式
英文:

How to install fastapi on an offline computer

问题

我正在学习Python,使用一个没有互联网连接的计算机。我需要安装FastAPI和Uvicorn。
在有互联网访问权限的计算机上,我只需要输入"pip install fastapi"和"pip install 'uvicorn[standard]'"。

但是我的计算机没有互联网连接。

我该如何安装FastAPI和Uvicorn?

在哪里可以下载离线安装程序?以及在pip中要输入什么?

我从这里https://pypi.org/project/fastapi-offline/#files 下载了FastAPI的离线安装程序。
但安装失败了。

英文:

I am learning python on a computer without internet. I need to install fastapi and uvicorn.
On a computer with internet access, I would just have to type "pip install fastapi" and 'pip install "uvicorn[standard]"'.

But my computer is not connected to the internet.

How do I install fastapi and uvicorn?

Where can I download offline installers? And what to type in pip?

I downloaded fastapi_offline from here https://pypi.org/project/fastapi-offline/#files
But the installation failed.

答案1

得分: 1

如果您有这个选项,使用pip download是一个不错的选择,因为这将包括所有的传递依赖项(即FastAPI所依赖的一切,以及那些依赖项所依赖的一切等等)。对于当前版本的FastAPI和uvicorn,这将涵盖以下这些包和版本:

anyio-3.6.2-py3-none-any.whl
click-8.1.3-py3-none-any.whl
colorama-0.4.6-py2.py3-none-any.whl
fastapi-0.92.0-py3-none-any.whl
h11-0.14.0-py3-none-any.whl
idna-3.4-py3-none-any.whl
pydantic-1.10.5-cp310-cp310-win_amd64.whl
sniffio-1.3.0-py3-none-any.whl
starlette-0.25.0-py3-none-any.whl
typing_extensions-4.5.0-py3-none-any.whl
uvicorn-0.20.0-py3-none-any.whl

由于每个包的平台都是none,它们应该可以在Windows、OS X和Linux上都运行。

如果您需要数据库库(如SQLAlchemy),所需的包数量将大大增加。

即使您无法在要下载包的计算机上安装任何东西,如果您可以使用USB驱动器从该计算机获取包,您可以在USB驱动器上安装python/pip,然后使用该pip可执行文件来为您下载包。有关详细信息,请参考这个链接

.whl文件可以通过在没有互联网访问权限的计算机上使用pip install <whl文件>来安装。

英文:

If you have the option, using pip download is the way to go, since this will also include and transient dependencies (i.e. everything that FastAPI depends on, and everything those packages depends on, etc.). For the current version of FastAPI and uvicorn, this ends up being these packages and versions:

anyio-3.6.2-py3-none-any.whl
click-8.1.3-py3-none-any.whl
colorama-0.4.6-py2.py3-none-any.whl
fastapi-0.92.0-py3-none-any.whl
h11-0.14.0-py3-none-any.whl
idna-3.4-py3-none-any.whl
pydantic-1.10.5-cp310-cp310-win_amd64.whl
sniffio-1.3.0-py3-none-any.whl
starlette-0.25.0-py3-none-any.whl
typing_extensions-4.5.0-py3-none-any.whl
uvicorn-0.20.0-py3-none-any.whl

Since every package has none as its platform, they should all work on both Windows, OS X and Linux.

If you want database libraries (such as SQLAlchemy), the number of required packages will grow a lot.

Even if you can't install anything on the computer where you want to download the packages, if you can get the packages off that computer with a usb drive, you can install python/pip on the USB drive, and then use that pip executable to download the packages for you.

The .whl-files can be installed using pip install &lt;whl file&gt; on your computer without internet access..

huangapple
  • 本文由 发表于 2023年2月27日 00:53:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75573551.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定