1

I have multiple python installs on a network drive (2.6, 2.7 each in 32 and 64 bits). I wanna update/delete/install packages on one of them but I wanna test if it doesn't break anything before putting my changes in production. So I made a copy of, let's say, Python 2.7 64 bits and started modifying packages with pip. Only to notice a few minutes later that the pip from the copied folder I was using was still pointing to the python install I copied it from. How can I make it point to the new folder?

After that I also tried using a virtualenv but some of the packages in production are a bit old and some of them could not be found on PyPi so doing a pip freeze in a requirements.txt then trying to install from it didn't work pretty well. Also i'm gonna have the same issue in the other way.

Tadhg McDonald-Jensen
  • 20,699
  • 5
  • 35
  • 59
Narthe
  • 492
  • 1
  • 4
  • 16
  • 3
    Look into [virtualenv](https://virtualenv.pypa.io/en/stable/) – Nir Alfasi Jun 20 '17 at 14:57
  • 1
    Are you refering to the --relocatable option of virtualenv ? Many people say it has some issues, i wanted to know if there was no safer way – Narthe Jun 20 '17 at 15:00
  • 2
    [`virtualenv`](https://virtualenv.pypa.io/en/stable/) is definitely the right way to deal with multiple environments. If you want consistency between them then you can use [`pip freeze`](https://pip.pypa.io/en/stable/reference/pip_freeze/) in order generate a list of installed packages which you can install then in another environment. See [this answer](https://stackoverflow.com/a/7438771/3767239). – a_guest Jun 20 '17 at 15:04
  • 1
    When you mention that some packages could not be found on PyPi because they are old, how did they get on the production machine then? I would still suggest using `virtualenv` with `pip freeze` and installing those old packages manually, however you did it before. In the worst case you can go to the `lib/python2.7/site-packages/` folder of your Python distribution and copy the `.py` and `.dist-info` files (or the package folders) manually. – a_guest Jun 20 '17 at 15:22
  • @a_guest I came way after the development of the software i'm working on started and the original devs never took the time to update the packages as long as the app. I think i'm gonna make the most up to date version of my virtual environnement i can, then use the pip freeze method. – Narthe Jun 20 '17 at 15:56
  • @Narthe When you say those packages are not available on PyPi, do you mean the packages themselves or just the specific versions? In the former case I would look for possibilities to replace those packages with ones from PyPi (unless they are intern). In the latter case checking if the application is compatible with a more recent version is a good option (usually there are good reasons for new versions to be released). If this is not an option, then you could really copy the source files of those packages. When you try `pip freeze` followed by `pip install`, could you share what exactly fails? – a_guest Jun 20 '17 at 16:20
  • @a_guest I mean specific versions, packages that are not updated anymore for python 2.7+ like libxml2-python or pyxslt. I had to find some builds elsewhere. – Narthe Jun 20 '17 at 18:09

0 Answers0