2

I want to download python libraries like NumPy, scipy, etc. in a separate folder. I want to include that folder in the python project so that whenever I switch to some other laptop, I don't need to install the libraries again rather I import libraries from that folder. Is there any way?

  • Does this answer your question? [How to move Python virtualenv to different system (computer) and use packages present in Site-packages](https://stackoverflow.com/questions/59460798/how-to-move-python-virtualenv-to-different-system-computer-and-use-packages-pr) – Narendra Prasath Jun 20 '20 at 05:25

4 Answers4

4

You can easily install python virtualenv.
Your libraries will be installed in directory created by virtualenv.
https://pypi.org/project/virtualenv/.

Other option, you can also use docker.

hwwwi
  • 186
  • 4
1

I suggest using virtual environment in this case. You could use pipenv so that the project hast exactly the libraries you need for it to run.

0

You can do it. for numpy library: https://pypi.org/project/numpy/#files You can download the files statically from pypi.

I would not recommend you go with this approach. There are several reasons to do that.

  • There would be a dependency on this kind of library. So you have to keep these dependencies along with the NumPy package.
  • These libraries are getting updated after some time with some newly added functionality and some bug fixes. So with the time other libraries might not compatible with this library.

Recommended way:

  • Just create an requirement.txt file that contains all the dependency with its version number.
  • whenever you want to use your project elsewhere, just install all these libraries with below command.

    pip install -r requirement.txt

Astik Gabani
  • 599
  • 1
  • 4
  • 11
0

There are two major way you can install python libs to a separate folder: a virtual environment or a container.

Virtula environment (like venv, pipenv, etc) is good as this is the simplest way to your project's own liblaries set which is not impact any other pythonic script in your system. The downside of this case is thet you really have to set up an environment (including lib install) on every computer you move your script to. This can and should be autimated, of course, but this should be done either way.

The container, in other hand, requires additional resources to handle and to build, build, but it is exactly the box with a specific version of your script along with all libs and binaries it requires. No need to reinstall libs while moving to new laptop/desktop/server/cloud/whatever. For this case I would recommend the Docker/Kubernetes. But it's better to start with Docker.