[PYTHON] [Solved] ImportError: No module named pyexpat and pyenv install is moss

~~ I'm sorry. It's still unsolved. If you have solved it in the past, I would appreciate it if you could give me some advice. ~~

It seems that it has moved somehow.

How to fix

Now it works! https://github.com/yyuu/pyenv/issues/448#issuecomment-220652296

export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix sqlite3)/lib"
export CPPFLAGS="-I$(brew --prefix sqlite3)/include"

But I don't know why it didn't work and why it was fixed. .. ..

The following process

I got an error when trying to install 3.5.2 with pyenv

$ pyenv install 3.5.2
Installing Python-3.5.2...

BUILD FAILED (OS X 10.12.1 using python-build 20160602)

Inspect or clean up the working tree at /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103191050.41922
Results logged to /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103191050.41922.log

Last 10 log lines:
    import pip
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmp3hlbqezp/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line 14, in <module>
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmp3hlbqezp/pip-8.1.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 27, in <module>
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmp3hlbqezp/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 36, in <module>
  File "/private/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103191050.41922/Python-3.5.2/Lib/plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
  File "/private/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103191050.41922/Python-3.5.2/Lib/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: No module named 'pyexpat'
make: *** [install] Error 1

Even on github, I was told "Because it's broken ('-`) Silane"

ImportError: No module named pyexpat · Issue #544 · yyuu/pyenv

Isn't pyenv installed via homebrew wrong?

I want to do something that wasn't there once.

Let's erase PYENV_ROOT

$ echo $PYENV_ROOT
/usr/local/var/pyenv
$ rm -r /usr/local/var/pyenv

For the time being, I will delete the association that I put in via brew

$ brew uninstall pyenv python

Install pyenv again

$ brew install pyenv

3.5.2 Re-challenge installation

$ pyenv install 3.5.2

No, it's no good!


Downloading Python-3.5.2.tar.xz...
-> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
Installing Python-3.5.2...

BUILD FAILED (OS X 10.12.1 using python-build 20160602)

Inspect or clean up the working tree at /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193542.66147
Results logged to /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193542.66147.log

Last 10 log lines:
    import pip
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmpsbqryzv7/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line 14, in <module>
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmpsbqryzv7/pip-8.1.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 27, in <module>
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmpsbqryzv7/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 36, in <module>
  File "/private/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193542.66147/Python-3.5.2/Lib/plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
  File "/private/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193542.66147/Python-3.5.2/Lib/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: No module named 'pyexpat'
make: *** [install] Error 1

Set up CFLAGS and try again

Refer to here ...

Python 3.4.2 doesn't build on OS X 10.10 Yosemite · Issue #298 · yyuu/pyenv

$ CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.5.2
Downloading Python-3.5.2.tar.xz...
-> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
Installing Python-3.5.2...

BUILD FAILED (OS X 10.12.1 using python-build 20160602)

Inspect or clean up the working tree at /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193925.80736
Results logged to /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193925.80736.log

Last 10 log lines:
    import pip
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmp7cp6pxz_/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line 14, in <module>
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmp7cp6pxz_/pip-8.1.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 27, in <module>
  File "/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/tmp7cp6pxz_/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 36, in <module>
  File "/private/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193925.80736/Python-3.5.2/Lib/plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
  File "/private/var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103193925.80736/Python-3.5.2/Lib/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: No module named 'pyexpat'
make: *** [install] Error 1

Will it change ...

Something 2 system is already moss

 $ pyenv install 2.7.12
Downloading Python-2.7.12.tar.xz...
-> https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
Installing Python-2.7.12...
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Installing pip from https://bootstrap.pypa.io/get-pip.py...
error: failed to install pip via get-pip.py

BUILD FAILED (OS X 10.12.1 using python-build 20160602)

Inspect or clean up the working tree at /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103194730.10697
Results logged to /var/folders/g5/b_nhsv5546g9pf7_k7xynpxw0000gn/T/python-build.20161103194730.10697.log

Last 10 log lines:
    info = _mac_ver_xml()
  File "/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/platform.py", line 739, in _mac_ver_xml
    pl = plistlib.readPlist(fn)
  File "/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/plistlib.py", line 78, in readPlist
    rootObject = p.parse(pathOrFile)
  File "/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/plistlib.py", line 401, in parse
    from xml.parsers.expat import ParserCreate
  File "/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: No module named pyexpat

Recommended Posts

[Solved] ImportError: No module named pyexpat and pyenv install is moss
python / netCDF / CentOS 6.8> ImportError: No module named netCDF4> sudo yum install netcdf4-python.x86_64
python> import seiral> ImportError: No module named serial
Install pyenv and pyenv-virtualenv
Resolve No module named tkinter
Django, nginx, uWSGI, virtualenv ImportError: No module named site Solution Note
'lambda_function': No module named When'selenium' appears
Install and configure `pyenv` Ansible playbook
Wall to put OpenCV 3.1.0 in raspberry pi 3 and run sample on python3: ImportError: No module named cv2 solution