How to Install Python Packages on an Offline PC with All Dependencies?

0
20
Asked By CuriousCoder27 On

I'm trying to figure out the best approach to install a Python package and all its dependencies on a computer that's offline. I've already implemented a method that worked well for me. Here's what I did:
1. I created a virtual environment using `python -m venv .` in a specific directory.
2. Then, I activated it with `.Scriptsactivate`.
3. After that, I installed the package using `pip install `.
4. I saved the dependencies with `pip freeze > requirements.txt`.
5. Next, I created a folder called 'wheel' and used `pip download -r requirements.txt` to fetch the wheels.
6. Finally, I moved the 'wheel' folder to the offline PC, created a new virtual environment there, and installed the packages using the wheels.

This method works great as long as all required files are available as wheel files. However, I've recently encountered packages that also need dependencies built from source, resulting in `tar.gz` files instead. These sources can't be built on the offline PC due to missing dependencies or issues with build tools and setuptools. Does anyone have a solution to get this working?

3 Answers

Answered By ContainerGuru42 On

Honestly, this sounds like a perfect use case for Docker or containerization. You can create an image with your entire environment set up and then run it on any computer without worrying about dependency issues.

Answered By TechWhiz123 On

Have you tried using Nuitka? It's a really helpful tool that can compile your code into a standalone application, and it might help with those pesky dependencies that need building from source.

Answered By PackagerPro99 On

I prefer to package my scripts into standalone executables. Sure, it makes the file size larger, but it simplifies deployment and keeps everything contained.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.