How do I install a pip package globally instead of locally?

后端 未结 5 1673
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 01:25

I am trying to install flake8 package using pip3 and it seems that it refuses to install because is already installed in one local location.

How can I force it to i

相关标签:
5条回答
  • 2020-12-08 01:55

    Maybe --force-reinstall would work, otherwise --ignore-installed should do the trick.

    0 讨论(0)
  • 2020-12-08 01:55

    Are you using virtualenv? If yes, deactivate the virtualenv. If you are not using, it is already installed widely (system level). Try to upgrade package.

    pip install flake8 --upgrade
    
    0 讨论(0)
  • 2020-12-08 02:04

    Why don't you try sudo with the H flag? This should do the trick.

    sudo -H pip install flake8
    

    A regular sudo pip install flake8 will try to use your own home directory. The -H instructs it to use the system's home directory. More info at https://stackoverflow.com/a/43623102/

    0 讨论(0)
  • 2020-12-08 02:10

    I actually don‘t see your issue. Globally is any package which is in your python3 path‘s site package folder.

    If you want to use it just locally then you must configure a virtualenv and reinstall the packages with an activated virtual environment.

    0 讨论(0)
  • 2020-12-08 02:15

    Where does pip installations happen in python?

    I will give a windows solution which I was facing and took a while to solve.

    First of all, in windows (I will be taking Windows as the OS here), if you do pip install <package_name>, it will be by default installed globally (if you have not activated a virtual enviroment). Once you activate a virtual enviroment and you are inside it, all pip installations will be inside that virtual enviroment.


    pip is installing the said packages but not I cannot use them?

    For this pip might be giving you a warning that the pip executables like pip3.exe, pip.exe are not on your path variable. For this you might add this path ( usually - C:\Users\<your_username>\AppData\Roaming\Programs\Python\ ) to your enviromental variables. After this restart your cmd, and now try to use your installed python package. It should work now.

    0 讨论(0)
提交回复
热议问题