2

First, my reasons to do this - I know it's a bad idea but I am out of ideas.

I want to install a package which requires a ld version, which is higher than the one in the repo of my Centos 6.5. So I should either go for setting up everything in a Docker and running it in production - something I lack experience with and I don't feel comfortable doing for a serious project. Or upgrade ld manually building from external source. Which I read, could result in devastation of my Centos. So the last option I am left with is install the packed on other machine and manually copy it to site-packages.

I have successfully installed the package on my home laptop under Debian.

I encountered everywhere advice to copy the whole site-packages directory. Something which I don't want to do as I have different packages on both machines and I want to avoid messing up with other stuff.

I copied the .so build and .egginfo of the package. Then, on the target machine, pip freeze indeed showed me the transferred package. However, Python can't find it when I try to import and use it.

Am I missing something else?

Nikolay Shindarov
  • 1,616
  • 2
  • 18
  • 25

1 Answers1

2

Not any of that.

Don't mess with system Python's site-packages dir, this belongs to the system Python env only. You should only add/remove code in there by using the package manager of your OS (that's yum for CentOS). This is especially true in Linux where many OS services can rely on system Python.

So what to do instead? Use a virtualenv and/or pipx to isolate any other dependencies of the package you want to install from the system versions.

wim
  • 338,267
  • 99
  • 616
  • 750
  • Do you mean to create a virtualenv on the Debian where I can install the package, install all other packages I need in it, and copy the entire virutalenv folder on the target Centos server, then run my app using the virtualenv? – Nikolay Shindarov Oct 28 '19 at 23:28
  • First let me clarify, is the only thing that you need a newer version of ld (The GNU linker) to *install* the Python package from source? If that's the case, I think you should just `altinstall` a newer linker (or just prepend one in PATH temporarily) and build a Python bdist for this package. – wim Oct 28 '19 at 23:35
  • It seems so, I was told its version is too old by the package dev, the package itself has no other pip dependencies. On my Debian it installed immediately. – Nikolay Shindarov Oct 28 '19 at 23:37
  • I don't want to install any linker out of the repo as I don't want to take any risk. I read the consequences can be dramatic and this is a production server. – Nikolay Shindarov Oct 28 '19 at 23:39
  • You don't have to install it. Just prepend a newer linker from your homedir on the PATH temporarily, or use an environment module. Then do `python setup.py bdist_wheel` to build a bdist file which you can use going forward, without needing a linker at install time anymore. – wim Oct 28 '19 at 23:40
  • Sorry, I am not familiar with this stuff. No idea where to get a newer version which to prepend, etc... I guess your idea for virtualnv is good so I am accepting your answer. Thank you for your time. – Nikolay Shindarov Oct 28 '19 at 23:55