Maintaining a truly independent Python installation

I am working on a cluster, and the cluster already has a python installation on it.

But, like my relationship with R, I would like to support a local independent Python installation. It seems to me that the authors never assumed that there would be a python.

I installed python with the -prefix tag and later received an error from pip when installing packages on a local installation, because the local installation was the source of packages from a specific server folder /usr/lib/pythonX.Y/dist-packages/. A simple fix would be to recompile my version so that it uses the same USC4 encoding as the system-wide installation.

But I do not want to do this, because I would like to be free from various uncontrollable variables that affect our cluster OS, which lead to an incident when the entire OS must be updated.

sys.path is the culprit who creates this path /usr/lib/pythonX.Y/ using os.path in the site.py file and then imports it.

How can I permanently remove this path from my python installation? preferably during compilation of Python itself. I only resort to modifying site.py after I find out that there is no other way for me to do this.

UPDATE:

So now I have switched to using pyenv. But I do not think that this is the optimal solution to the problem. I would really like to know why this explicit decision was made by the python authors to get the system-wide paths to any local python installation.

UPDATE 04/12/2016:

Anaconda, , , ..

  • python, , , , , , . ,

    sys.path , . Anaconda sys.path lib .

    import sys

    from pprint import pprint as p

        p(sys.path)
        ['',
         '/home/kpal/anaconda2/bin',
         '/usr/lib/pymodules/python2.7',
         '/home/kpal/.local/lib/python2.7/site-packages/cooler-0.3.0-py2.7.egg',
         '/home/kpal/.local/lib/python2.7/site-packages/hiclib-0.0.0-py2.7-linux-x86_64.egg',
         '/home/kpal/.local/lib/python2.7/site-packages/mirnylib-0.0.0-py2.7-linux-x86_64.egg',
         '/home/kpal/anaconda2/lib/python27.zip',
         '/home/kpal/anaconda2/lib/python2.7',
         '/home/kpal/anaconda2/lib/python2.7/plat-linux2',
         '/home/kpal/anaconda2/lib/python2.7/lib-tk',
         '/home/kpal/anaconda2/lib/python2.7/lib-old',
         '/home/kpal/anaconda2/lib/python2.7/lib-dynload',
         '/home/kpal/.local/lib/python2.7/site-packages',
         '/home/kpal/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg',
         '/home/kpal/anaconda2/lib/python2.7/site-packages/setuptools-20.3-py2.7.egg',
         '/home/kpal/anaconda2/lib/python2.7/site-packages',
         '/home/kpal/anaconda2/lib/python2.7/site-packages/IPython/extensions',
         '/home/kpal/.ipython']
    
  • Anaconda , ( / ). , python install "package" --user

/home/user/.local/. , , .

+4
2

Anaconda, , , ..

  • python, , , , , , . ,

    sys.path , . Anaconda sys.path lib .

    import sys

    from pprint import pprint as p

        p(sys.path)
        ['',
         '/home/kpal/anaconda2/bin',
         '/usr/lib/pymodules/python2.7',
         '/home/kpal/.local/lib/python2.7/site-packages/cooler-0.3.0-py2.7.egg',
         '/home/kpal/.local/lib/python2.7/site-packages/hiclib-0.0.0-py2.7-linux-x86_64.egg',
         '/home/kpal/.local/lib/python2.7/site-packages/mirnylib-0.0.0-py2.7-linux-x86_64.egg',
         '/home/kpal/anaconda2/lib/python27.zip',
         '/home/kpal/anaconda2/lib/python2.7',
         '/home/kpal/anaconda2/lib/python2.7/plat-linux2',
         '/home/kpal/anaconda2/lib/python2.7/lib-tk',
         '/home/kpal/anaconda2/lib/python2.7/lib-old',
         '/home/kpal/anaconda2/lib/python2.7/lib-dynload',
         '/home/kpal/.local/lib/python2.7/site-packages',
         '/home/kpal/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg',
         '/home/kpal/anaconda2/lib/python2.7/site-packages/setuptools-20.3-py2.7.egg',
         '/home/kpal/anaconda2/lib/python2.7/site-packages',
         '/home/kpal/anaconda2/lib/python2.7/site-packages/IPython/extensions',
         '/home/kpal/.ipython']
    
  • Anaconda , ( / ). , python install "package" --user

/home/user/.local/. , , .

0

. python. , , . python .

+2

Source: https://habr.com/ru/post/1615588/


All Articles