Inside virtual env, “sudo pip” links to the global python pip

前端 未结 3 1259
不知归路
不知归路 2021-01-17 17:06

Working inside a vagrant environment, inside a python virtual environment, when I try to install a python package using

(venv) vagrant@vagrant-ubuntu-trusty         


        
3条回答
  •  [愿得一人]
    2021-01-17 17:45

    I had the same problem with pip vs sudo pip and virtualenv pip vs local pip. I was logged in as root user when I created my venv months ago. So when I wanted to install a new pip package got permission denied. So tried the same command with sudo, but then it installed the package on my local pip.

    Lesson learned. I should not use sudo inside a venv.

    Fixed it with:

    chmod -R 0777 venv_folder_path_here
    

    -R switch for recursive change in venv folder.

    And then activate your venv and try pip install:

    /home/username_here/venv/project_name_here/bin/activate
    (venv_name) pip install package_name_here
    

提交回复
热议问题