-1

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.

mml
  • 21
  • 3
  • Have you seen `pip download`? https://pip.pypa.io/en/stable/cli/pip_download/ – MatsLindh Feb 26 '23 at 20:43
  • Yes i've seen pip_download and pip_install explanations. How i understood to make sense to use the pip only on the computer connected to internet. – mml Feb 27 '23 at 09:47
  • Unfortunately my computer connected to the internet work under Windows7. I can not install python and pip on this computer.I think I can download fastapi from here https://pypi.org/project/fastapi/#files. Only I don't know what to download fastapi-0.92.0.tar.gz or fastapi-0.92.0-py3-none-any.whl? In what directory should I put the downloaded files on the computer where python is installed? And what command to type in pip to install from the downloaded file without accessing the Internet? – mml Feb 27 '23 at 10:05
  • The `whl` file is usually everything bundled in a single file (for that single package). You can install the whl file using `pip install `. See https://stackoverflow.com/questions/27885397/how-do-i-install-a-python-package-with-a-whl-file - you'll still need to fetch the dependencies as well, which is what `pip download` does for you, so you'll probably have some trouble going through and fetching every dependency. – MatsLindh Feb 27 '23 at 10:24
  • Yes, I am also afraid that I will need to download many more modules besides fastapi. Is there a command that will show all dependent modules? Or how do I know which ones to download? – mml Feb 27 '23 at 10:40
  • I've added an answer which includes a list of everything downloaded when doing `pip download fastapi` and `pip download uvicorn`. You can also give `--dry-run` to `pip install` to just let it simulate what it'd do. This will show you everything that would have been installed when running the command. – MatsLindh Feb 27 '23 at 10:42

1 Answers1

1

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 <whl file> on your computer without internet access..

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • Have you shown a complete list of what to download? Thank you very much! Does the installation order matter? – mml Feb 27 '23 at 10:43
  • Those are the packages that gets downloaded if you try to install fastapi and uvicorn today, yes. You'll probably want to install everything other than fastapi and uvicorn first at least, but it should tell you if it expects something to be present if it's not - and I'm guessing you can install multiple packages at the same time and let `pip` work it out for you (.. but I haven't tested that). – MatsLindh Feb 27 '23 at 10:49
  • Very interesting idea to install python on USB! And then, as I understand it, plug it into a computer with WIN7, which is connected to the Internet. And pip should work. Did I understand correctly? – mml Feb 27 '23 at 10:51
  • Yep. You can then run `pip download` on your USB drive and get everything downloaded to a folder on the usb drive. You can then take this usb drive to your other computer and install everything there with `pip install`. – MatsLindh Feb 27 '23 at 10:58
  • Super! So I'll try. – mml Feb 27 '23 at 11:01
  • No python and pip not work from usb on the Win7 computer. – mml Feb 27 '23 at 14:30
  • Sorry, but as long as that's everything you're willing to say, without an error message or what's happening and what you tried, it'll be impossible for anyone to guide you in any other direction or make suggestions; you need to expand on _why_ something doesn't work or what you're trying to do. – MatsLindh Feb 27 '23 at 14:35
  • I installed Python 3.10.10 on the USB. When i insert it in Win7 computer. In cmd moved to F:\Scripts directory. Typed on the keyboard f:\python.exe f:\pip. A window appeared with a system error saying "api-ms-win-core-path-l1-1-0.dll is missing on the computer. Try reinstalling the program" – mml Feb 27 '23 at 15:01
  • So python shouldn't work on Win7. Will it run from a flash drive? – mml Feb 27 '23 at 15:04
  • I successfully downloaded everything according to your list and installed it. Thank you! – mml Feb 27 '23 at 15:48
  • Python 3.8 was the last that was compiled with Windows 7 support - so if you need support for Win7, that's the version you're going to have to use if you're downloading Python's own distributions. – MatsLindh Feb 27 '23 at 19:55