How to install python packages in virtualenv using sudo
Issue
=====
a)
I created a virtualenv ".venv" using following command in /opt
#cd /opt
#sudo virtualenv .venv
#source .venv/bin/activate
#sudo easy_install python-keystoneclient
But package not installing in virtualenv ".venv" instead it pointing to
/usr/local/lib/python2.7/dist-packages/python_keystoneclient-0.6.0.2.g43f8870-py2.7.egg
b)
(.venv2)saju@rildemo2:/opt/horizon_reg_service$ sudo easy_install python-keystoneclient
Searching for python-keystoneclient
Best match: python-keystoneclient 0.6.0.2.g43f8870
Processing python_keystoneclient-0.6.0.2.g43f8870-py2.7.egg
python-keystoneclient 0.6.0.2.g43f8870 is already the active version in easy-install.pth
Installing keystone script to /usr/local/bin
Using /usr/local/lib/python2.7/dist-packages/python_keystoneclient-0.6.0.2.g43f8870-py2.7.egg
Processing dependencies for python-keystoneclient
Finished processing dependencies for python-keystoneclient
(.venv2)saju@rildemo2:/opt/horizon_reg_service$
Solutions
==========
1) (Tested and working)
sudo is probably screwing with $PATH. delete the virtualenv, `sudo -i` to get a root shell, then make the virtualenv without sudo (as root)
#sudo -i
#cd /opt
#virtualenv .venv
#source .venv/bin/activate
#pip install python-keystoneclient
2)
the better thing to do would be to make the /opt/.venv folder, change the ownership to your user, and then do the virtualenv stuff as your normal user (without sudo)
Issue
=====
a)
I created a virtualenv ".venv" using following command in /opt
#cd /opt
#sudo virtualenv .venv
#source .venv/bin/activate
#sudo easy_install python-keystoneclient
But package not installing in virtualenv ".venv" instead it pointing to
/usr/local/lib/python2.7/dist-packages/python_keystoneclient-0.6.0.2.g43f8870-py2.7.egg
b)
(.venv2)saju@rildemo2:/opt/horizon_reg_service$ sudo easy_install python-keystoneclient
Searching for python-keystoneclient
Best match: python-keystoneclient 0.6.0.2.g43f8870
Processing python_keystoneclient-0.6.0.2.g43f8870-py2.7.egg
python-keystoneclient 0.6.0.2.g43f8870 is already the active version in easy-install.pth
Installing keystone script to /usr/local/bin
Using /usr/local/lib/python2.7/dist-packages/python_keystoneclient-0.6.0.2.g43f8870-py2.7.egg
Processing dependencies for python-keystoneclient
Finished processing dependencies for python-keystoneclient
(.venv2)saju@rildemo2:/opt/horizon_reg_service$
Solutions
==========
1) (Tested and working)
sudo is probably screwing with $PATH. delete the virtualenv, `sudo -i` to get a root shell, then make the virtualenv without sudo (as root)
#sudo -i
#cd /opt
#virtualenv .venv
#source .venv/bin/activate
#pip install python-keystoneclient
2)
the better thing to do would be to make the /opt/.venv folder, change the ownership to your user, and then do the virtualenv stuff as your normal user (without sudo)
No comments:
Post a Comment