how do I update PYTHONPATH from /usr/local/bin/python to /usr/bin/python

北城余情 提交于 2019-12-25 05:27:19

问题


I am unable to use virt-manager, and I think it's because of where my python is located. When I run the virt-manager command I get: No module named libvirt even though I have libvirt installed. When I run /usr/bin/python /usr/share/virt-manager/virt-manager.py it works fine. The output from which python is /usr/local/bin/python. I've tried creating a ~/.bash_profile that contains this: export PYTHONPATH=$PYTHONPATH:/usr/bin/python but am still having the same problem. I'm sure there is a simple solution to this?


回答1:


You can make a symbolyc link

sudo mv /usr/local/bin/python python-old #example name
sudo ln -s /usr/bin/python /usr/local/bin/python



回答2:


To be clear, the PYTHONPATH environmental variable sets where your python session looks for modules. It doesn't set the location of your python interpreter, which I think is what you want to do.

What you need to do is add and alias for the python interpreter that you do want to use to your bash_profile. Something like this:

alias python='/usr/bin/python'


来源:https://stackoverflow.com/questions/29970027/how-do-i-update-pythonpath-from-usr-local-bin-python-to-usr-bin-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!