0
我有2個python安裝一個用於root用戶,一個用於普通用戶。 我想爲普通用戶的python安裝運行root用戶的python程序。如何做呢 ?如何從Linux中的不同路徑運行python程序
python -c "import sys; print '\n'.join(sys.path)"
/home/ubuntu/anaconda2/lib/python27.zip
/home/ubuntu/anaconda2/lib/python2.7
/home/ubuntu/anaconda2/lib/python2.7/plat-linux2
/home/ubuntu/anaconda2/lib/python2.7/lib-tk
/home/ubuntu/anaconda2/lib/python2.7/lib-old
/home/ubuntu/anaconda2/lib/python2.7/lib-dynload
/home/ubuntu/anaconda2/lib/python2.7/site-packages
/home/ubuntu/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg
/home/ubuntu/anaconda2/lib/python2.7/site-packages/cryptography-1.0.2-py2.7-linux-x86_64.egg
/home/ubuntu/anaconda2/lib/python2.7/site-packages/setuptools-19.6.2-py2.7.egg
這是root用戶
sudo python -c "import sys; print '\n'.join(sys.path)"
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages/rlp-0.4.6-py2.7.egg
/usr/local/lib/python2.7/dist-packages/devp2p-0.8.0-py2.7.egg
/usr/local/lib/python2.7/dist-packages/ethereum-1.6.0-py2.7.egg
/usr/local/lib/python2.7/dist-packages/ethereum_serpent-2.0.2-py2.7-linux-x86_64.egg
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
我想運行使用水蟒蟒安裝Python程序。但我不想改變路徑,因爲有其他用戶使用root python安裝。總之,我想以anaconda的root用戶身份運行此程序,但不需要更改root用戶的默認python安裝路徑。
直接啓動所需的Python解釋器/版本?您可以使用'which'獲取完整路徑 – UnholySheep
在啓動根用戶腳本時更改PYTHONPATH環境變量:export PYTHONPATH =/home/ubuntu/anaconda2/lib/python2.7/site-packages /:$ PYTHONPATH',然後啓動像往常一樣的根Python腳本;應該管用。雖然我覺得很奇怪 – mguijarr