After an OSx update and installing a new version of python 2.7
my virtualevn
environment completely broke and I struggled in fixing it. I wasn't sure what caused it and went through a whole set of things that I did and read initially that didn't work are listed below. What solved my problem is provided in the answer section.
virtualenv
command not found:Related questions that helped me but did not provide the solution to my problem:
This didn't completely solved my problem. It is just to give you an idea of what steps I went through before I found the correct way to fix my python dev environment on my OSx.
Manually installed virtualenv following the instructions from here:
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-13.1.2.tar.gz tar xvfz virtualenv-13.1.2.tar.gz cd virtualenv-13.1.2 sudo python setup.py install
Manaully install pip
through 7: curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
After all this after creating a virtual environment my pip still installed the packages in the main python folder instead of installing them under the virtual environment and non of the threads here neither here helped. My solution to that was to run pip under my virtual env with the following options: 1- Activate the virtual environment so that $VIRTUAL_ENV
is set:
source venv/bin/activate
2- Forces pip to install in the right destination:
pip install --target=$VIRTUAL_ENV/lib/python2.7/site-packages
Something was badly broken and best way I fix my dev environment is provided in the answer to this question.
Mac OS X comes with Python 2.7 out of the box. In particular, you should always install Setuptools, as it makes it much easier for you to install and manage other third-party Python libraries.
Back in 2019, Apple announced its plans to deprecate the Python 2.7 scripting language. With the release of macOS Monterey, Apple made good on that promise. macOS devices that are on versions 12.3 and above will no longer be able to execute scripts and operations that run on Python 2.7.
Install Python 3 with the Official Installer First, download an installer package from the Python website. To do that, visit https://www.python.org/downloads/ on your Mac; it detects your operating system automatically and shows a big button for downloading the latest version of Python installer on your Mac.
In my case was an OSx upgrade that affected my homebrew and after upgrading to python 2.7.11 is didn't install it properly.
I found steps 3 and 4 in a thread here and many thanks to https://github.com/baronomasia.
1 - Removed python 2.7 by using the post in here
2 - Removed the homebrew python installed version
brew uninstall python
3- Reinstall your Xcode command tools:
sudo xcode-select --install
4- Upgrade homebrew and reinstall python through homebrew:
brew update && brew reinstall python
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