2

I have a specific Python module that I wrote that I want to add to my CentOS server. I'm not sure where to add it though...

In Windows, its pretty easy, just drop it in C:\Python2.X\Lib or site-packages and Python finds it. I'm not sure how to accomplish the same thing in Linux.

Do I need to use yum somehow? Or do I simply have to manually specify the script path before calling the module?

Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
  • doh! I mean't to post this on SF... please migrate if necessary. Although I guess technically this is borderline programming related. – Jake Wilson Mar 21 '11 at 00:49
  • 1
    Which Python version? If it is >=2.6, you can copy the packages to `~/.local/lib/python2.6/site-packages` (read PEP 370 for details) – Sridhar Ratnakumar Mar 21 '11 at 19:27

2 Answers2

4

The clean option: write a setup.py, then run that.

The quick option: drop it in /usr/local/lib/python2.X/site-packages.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
2

If you want to install the package globally, use this command:

$ python -c "import site; print site.getsitepackages()" # Python >= 2.7

If you're fine with per-user installation, use this command:

$ python -c "import site; print site.getusersitepackages()" # Python >= 2.7

This will print the directories that you should put your source in...or even better, check this duplicate's accepted response:

How do I find the location of my Python site-packages directory?

Community
  • 1
  • 1
mjbommar
  • 489
  • 3
  • 8