As of December 26, 2015, if you install Python 2.x series with homebrew, 2.7.10 named 2.7.11 will be installed. This 2.7.11 has some bugs and some modules such as Django don't work well.
After installing Django
python manage.py runserver
Then
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 10, in <module>
from django.apps import apps
File "/usr/local/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module>
from .config import AppConfig
File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 5, in <module>
from django.utils._os import upath
File "/usr/local/lib/python2.7/site-packages/django/utils/_os.py", line 5, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Is that? ?? ?? I get an error. Aside from the details, it seems that it is due to a bug in Python 2.7.11, so I would like to downgrade to 2.7.10. .. ..
brew search <package_name>
It seems that you can select the version as long as it can be searched with, but there seems to be no way to install and sort Python 2.7.10 and 2.7.11. Then what should we do?
I thought about various methods, but decided to edit Formula directly. Delete python once.
brew remove python
The Formula remains, so edit it.
brew edit python
Edit the version.
class Python < Formula
desc "Interpreted, interactive, object-oriented programming language"
homepage "https://www.python.org"
head "https://hg.python.org/cpython", :using => :hg, :branch => "2.7"
- url "https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz"
+ url "https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz"
In brew edit, vi starts, so edit it normally and save it. After saving, try install again.
brew install python
Then, of course, there will be a SHA256 mismatch.
==> Downloading https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: 82929b96fd6afc8da838b149107078c02fa1744b7e60999a8babbc0d3fa86fc6
Actual: eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Archive: /Library/Caches/Homebrew/python-2.7.10.tgz
To retry an incomplete download, remove the file above.
Since Actual is the actual code, copy it and set it again as the expected value of the Formula.
class Python < Formula
desc "Interpreted, interactive, object-oriented programming language"
homepage "https://www.python.org"
head "https://hg.python.org/cpython", :using => :hg, :branch => "2.7"
url "https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz"
+ sha256 "eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a"
Now run install again.
brew install python
It looks like Python 2.7.10 has been successfully installed.
Now let's try to start the test server.
python manage.py runserver
It seems to have started successfully.
Recommended Posts