Pip Install not installing into correct directory?

前端 未结 10 1065
小蘑菇
小蘑菇 2020-11-29 04:22

I can\'t seem to use sudo pip install correctly so that it installs into the following directory:

/Library/Frameworks/Python.framework/Versions/2.7/lib/pyth         


        
相关标签:
10条回答
  • 2020-11-29 04:26

    Make sure you pip version matches your python version.

    to get your python version use:

    python -V

    then install the correct pip. You might already have intall in that case try to use:

    pip-2.5 install ...

    pip-2.7 install ...

    or for those of you using macports make sure your version match using.

    port select --list pip

    then change to the same python version you are using.

    sudo port select --set pip pip27

    Hope this helps. It work on my end.

    0 讨论(0)
  • 2020-11-29 04:30

    From the comments to the original question, it seems that you have multiple versions of python installed and that pip just goes to the wrong version.

    First, to know which version of python you're using, just type which python. You should either see:

    which python
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python
    

    if you're going to the right version of python, or:

    which python
    /usr/bin/python
    

    If you're going to the 'wrong' version. To make pip go to the right version, you first have to change the path:

     export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python:${PATH}
    

    typing 'which python' would now get you to the right result. Next, install pip (if it's not already installed for this installation of python). Finally, use it. you should be fine now.

    0 讨论(0)
  • 2020-11-29 04:35

    You could just change the shebang line. I do this all the time on new systems.

    If you want pip to install to a current version of Python installed just update the shebang line to the correct version of pythons path.

    For example, to change pip (not pip3) to install to Python 3:

    #!/usr/bin/python
    

    To:

    #!/usr/bin/python3
    

    Any module you install using pip should install to Python not Python.

    Or you could just change the path.

    0 讨论(0)
  • 2020-11-29 04:39

    I totally agree with the guys, it's better to use virtualenv so you can set a custom environment for every project. It ideal for maintenance because it's like a different world for every project and every update of an application you make won't interfere with other projects.

    Here you can find a nutshell of virtualenv related to installation and first steps.

    0 讨论(0)
  • 2020-11-29 04:40

    I've tried this and it worked for me,

    curl -O  https://files.pythonhosted.org/packages/c0/4d/d2cd1171f93245131686b67d905f38cab53bf0edc3fd1a06b9c667c9d046/boto3-1.14.29.tar.gz
    
    tar -zxvf boto3-1.14.29.tar.gz
    
    cd boto3-1.14.29/
    

    Replace X with your required python interpreter, for mine it was python3

    sudo pythonX setup.py install
    
    0 讨论(0)
  • 2020-11-29 04:47

    This is what worked for me on Windows. The cause being multiple python installations

    1. update path with correct python
    2. uninstall pip using python -m pip uninstall pip setuptools
    3. restart windows didn't work until a restart
    0 讨论(0)
提交回复
热议问题