1

I'm wondering how to install two different versions of a module for python. I host some scripts on a server and some particular ones require older version of the module because some things just doesn't work in the newer version and vice versa, some things doesn't work on the older version.

I know i can use pkg_resources and require a certain version, but if i try to install and use another version it just replaces the other one.

5
  • 4
    You can use virtual environment in Python. With virtual environment, you can install different versions of a module. You can find more information here: docs.python.org/3/tutorial/venv.html Commented Apr 6, 2021 at 21:05
  • 1
    are you using virtual environments? Commented Apr 6, 2021 at 21:05
  • 1
    An alternative to a virtual environment is to update your older scripts to work with a more current package. Newer packages may contain fixes and vulnerability patches. If that is not practical to update your older scripts, then you will need to use a virtual environment as noted by m.i.cosacak. Commented Apr 6, 2021 at 21:14
  • Thank you will look into that! @m.i.cosacak Commented Apr 6, 2021 at 21:14
  • I can't update them because newer versions caused some issues with functions, and they're not fixed yet, maybe in future releases. @cadvena Commented Apr 6, 2021 at 21:20

1 Answer 1

2

Easiest solution would be to use virtual environments for one or both of your scripts. This is however not recommended in the long run if you want to scale and manage. You should switch up the script using the older version or move to something like a docker based solution.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you explain the docker based solution a bit more?
Docker is a containerisation tool that can deliver software packages in something called a container. These containers are isolated from each other and hence can have different packages. You can take a look at this tutorial for an idea on how to create docker images geeksforgeeks.org/how-to-run-a-python-script-using-docker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.