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?
Virtualenv is only installed on DreamHost servers for Python 2. If you're working with Python 3, you must install virtualenv using pip3. pip3 is not installed on the server by default. You must first install a custom version of Python 3.
Instead of using brew you can simply use "venv".
To create a virtual environment you can run -->
python3 -m venv environment_name
Example: If you want to create an virtual environment for django with name django_env
python3 -m venv django_env
"-m" flag checks for sys.path and executes main module.
Activation of Virtual Environment :
source django_env/bin/activate
Deactivation :
deactivate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With