0

I am having 2 python installation one for root user and one for normal user. I want to run a python program for root user with the python installation for normal user. how can it be done ?

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

This is for the root user

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

I want to run a python program using the anaconda python installation. but i dont want to change the path as there are other users using root python installation. In summary i want to run this program as root user with anaconda but without changing the default python installation path for root user.

2
  • 4
    start the desired Python interpreter/version directly? You can get the full path using which Commented Dec 1, 2016 at 9:38
  • Change PYTHONPATH environment variable when starting the root user script: export PYTHONPATH=/home/ubuntu/anaconda2/lib/python2.7/site-packages/:$PYTHONPATH, then start the root Python script as usual ; should work. Although I find it weird Commented Dec 1, 2016 at 9:43

1 Answer 1

1

Just specify the full path to the python installation you want to run.

sudo /home/ubuntu/anaconda2/bin/python -c "import sys; print '\n'.join(sys.path)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.