[Python] How to correctly install python3 and virtualenv on MacOS Mojave?

Discussão em 'Python' iniciado por Stack, Março 18, 2025.

  1. Stack

    Stack Membro Participativo

    I start to learn Django framework so I need to install latest python, pip, virtualenv and django packets on my mac. I try to do it with brew, but I got some strange behavior.

    At first, python3 installed not in /usr/bin/ but in /Library/Frameworks/Python.framework directory:

    $ which python
    /usr/bin/python
    $ which python3
    /Library/Frameworks/Python.framework/Versions/3.7/bin/python3


    It is strange for me, because every tutorial tells about /usr/bin/python37 and nothing about /Library/Frameworks/Python.framework Is this okay?

    After that I made sudo pip3 install virtualenv and got this answer:

    The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.


    Okay, I made uninstall and install with -H sudo flag:

    Installing collected packages: virtualenv
    Successfully installed virtualenv-16.4.3


    But when I try to make a virtual environment, I got

    $ virtualenv venv
    -bash: /usr/local/bin/virtualenv: No such file or directory


    Checking virtualenv location:

    $ which virtualenv
    /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenv


    Why /Library/Frameworks/Python.framework/? And why it searches for virtualenv in /usr/local/bin/virtualenv? Coding on Macos is always so painful?

    Continue reading...

Compartilhe esta Página