Failed to import the site module Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x

Tags: pythonpath
Question!

I suspect this issue is a new issue associated with some patch on the OS X El Capitan 10.11.6

I installed anaconda4.1.1 (Python3.5.2). I create a symbolic link on /usr/local/bin to point to this newer python.

When I type python, I get this error

python3 Failed to import the site module Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x! PYTHONPATH is currently: "/Users/mpmac/anaconda/lib/python3.5/site-packages/" You should unset PYTHONPATH to fix this.

Once unset PYTHONPATH, I get this error: python Error in sitecustomize; set PYTHONVERBOSE for traceback: KeyError: 'PYTHONPATH' Python 3.5.2 |Anaconda 4.1.1 (x86_64)| (default, Jul 2 2016, 17:52:12) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin Type "help", "copyright", "credits" or "license" for more information.

I set PYTHONVERBOSE TO TRUE and got this result below. Somehow the loading of python moves from 3.5.2 to 2.7 on the sitecustomize package.

Any advice would be be helpful.

Thanks,

MacBook-Air:~ mpmac$ python import _frozen_importlib # frozen import _imp # builtin import sys # builtin import '_warnings' # import '_thread' # import '_weakref' # import '_frozen_importlib_external' # import '_io' # import 'marshal' # import 'posix' # import _thread # previously loaded ('_thread') import '_thread' # import _weakref # previously loaded ('_weakref') import '_weakref' #

installing zipimport hook import 'zipimport' #

installed zipimport hook

/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/init.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/encodings/init.py

code object from '/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/init.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/codecs.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/codecs.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/codecs.cpython-35.pyc'

import '_codecs' # import 'codecs' # <_frozen_importlib_external.SourceFileLoader object at 0x100720320>

/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/aliases.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/encodings/aliases.py

code object from '/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/aliases.cpython-35.pyc'

import 'encodings.aliases' # <_frozen_importlib_external.SourceFileLoader object at 0x100731ef0> import 'encodings' # <_frozen_importlib_external.SourceFileLoader object at 0x1003dfef0>

/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/utf_8.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/encodings/utf_8.py

code object from '/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/utf_8.cpython-35.pyc'

import 'encodings.utf_8' # <_frozen_importlib_external.SourceFileLoader object at 0x100740cc0> import '_signal' #

/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/latin_1.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/encodings/latin_1.py

code object from '/Users/mpmac/anaconda/lib/python3.5/encodings/pycache/latin_1.cpython-35.pyc'

import 'encodings.latin_1' # <_frozen_importlib_external.SourceFileLoader object at 0x100732780>

/Users/mpmac/anaconda/lib/python3.5/pycache/io.cpython-35.pyc matches /Users/mpmac/anaconda/lib/python3.5/io.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/io.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/abc.cpython-35.pyc matches /Users/mpmac/anaconda/lib/python3.5/abc.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/abc.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/_weakrefset.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/_weakrefset.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/_weakrefset.cpython-35.pyc'

import '_weakrefset' # <_frozen_importlib_external.SourceFileLoader object at 0x100748400> import 'abc' # <_frozen_importlib_external.SourceFileLoader object at 0x100732be0> import 'io' # <_frozen_importlib_external.SourceFileLoader object at 0x100732978>

/Users/mpmac/anaconda/lib/python3.5/pycache/site.cpython-35.pyc matches /Users/mpmac/anaconda/lib/python3.5/site.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/site.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/os.cpython-35.pyc matches /Users/mpmac/anaconda/lib/python3.5/os.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/os.cpython-35.pyc'

import 'errno' #

/Users/mpmac/anaconda/lib/python3.5/pycache/stat.cpython-35.pyc matches /Users/mpmac/anaconda/lib/python3.5/stat.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/stat.cpython-35.pyc'

import '_stat' # import 'stat' # <_frozen_importlib_external.SourceFileLoader object at 0x1007d0400>

/Users/mpmac/anaconda/lib/python3.5/pycache/posixpath.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/posixpath.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/posixpath.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/genericpath.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/genericpath.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/genericpath.cpython-35.pyc'

import 'genericpath' # <_frozen_importlib_external.SourceFileLoader object at 0x1007d1c88> import 'posixpath' # <_frozen_importlib_external.SourceFileLoader object at 0x1007d0748>

/Users/mpmac/anaconda/lib/python3.5/pycache/_collections_abc.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/_collections_abc.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/_collections_abc.cpython-35.pyc'

import '_collections_abc' # <_frozen_importlib_external.SourceFileLoader object at 0x1007d8320> import 'os' # <_frozen_importlib_external.SourceFileLoader object at 0x10075c1d0>

/Users/mpmac/anaconda/lib/python3.5/pycache/_sitebuiltins.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/_sitebuiltins.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/_sitebuiltins.cpython-35.pyc'

import '_sitebuiltins' # <_frozen_importlib_external.SourceFileLoader object at 0x10075c4a8>

/Users/mpmac/anaconda/lib/python3.5/pycache/sysconfig.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/sysconfig.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/sysconfig.cpython-35.pyc'

import 'sysconfig' # <_frozen_importlib_external.SourceFileLoader object at 0x101320438>

/Users/mpmac/anaconda/lib/python3.5/pycache/_sysconfigdata.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/_sysconfigdata.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/_sysconfigdata.cpython-35.pyc'

import '_sysconfigdata' # <_frozen_importlib_external.SourceFileLoader object at 0x101324d30>

/Users/mpmac/anaconda/lib/python3.5/pycache/_osx_support.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/_osx_support.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/_osx_support.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/re.cpython-35.pyc matches /Users/mpmac/anaconda/lib/python3.5/re.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/re.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/sre_compile.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/sre_compile.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/sre_compile.cpython-35.pyc'

import '_sre' #

/Users/mpmac/anaconda/lib/python3.5/pycache/sre_parse.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/sre_parse.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/sre_parse.cpython-35.pyc'

/Users/mpmac/anaconda/lib/python3.5/pycache/sre_constants.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/sre_constants.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/sre_constants.cpython-35.pyc'

import 'sre_constants' # <_frozen_importlib_external.SourceFileLoader object at 0x10137f438> import 'sre_parse' # <_frozen_importlib_external.SourceFileLoader object at 0x101373b00> import 'sre_compile' # <_frozen_importlib_external.SourceFileLoader object at 0x10133ab38> import '_locale' #

/Users/mpmac/anaconda/lib/python3.5/pycache/copyreg.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/copyreg.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/copyreg.cpython-35.pyc'

import 'copyreg' # <_frozen_importlib_external.SourceFileLoader object at 0x10138a1d0> import 're' # <_frozen_importlib_external.SourceFileLoader object at 0x101337c50> import '_osx_support' # <_frozen_importlib_external.SourceFileLoader object at 0x101328da0>

/Users/mpmac/anaconda/lib/python3.5/pycache/_bootlocale.cpython-35.pyc

matches /Users/mpmac/anaconda/lib/python3.5/_bootlocale.py

code object from '/Users/mpmac/anaconda/lib/python3.5/pycache/_bootlocale.cpython-35.pyc'

import '_bootlocale' # <_frozen_importlib_external.SourceFileLoader object at 0x10138a0f0>

/usr/local/lib/python2.7/site-packages/pycache/sitecustomize.cpython-35.pyc

matches /usr/local/lib/python2.7/site-packages/sitecustomize.py

code object from '/usr/local/lib/python2.7/site-packages/pycache/sitecustomize.cpython-35.pyc'

Failed to import the site module Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x! PYTHONPATH is currently: "/Users/mpmac/anaconda/lib/python3.5/site-packages/" You should unset PYTHONPATH to fix this.

destroy sitecustomize

destroy site

clear builtins._

clear sys.path

clear sys.argv

clear sys.ps1

clear sys.ps2

clear sys.last_type

clear sys.last_value

clear sys.last_traceback

clear sys.path_hooks

clear sys.path_importer_cache

clear sys.meta_path

clear sys.interactivehook

clear sys.flags

clear sys.float_info

restore sys.stdin

restore sys.stdout

restore sys.stderr

cleanup[2] removing encodings.latin_1

cleanup[2] removing builtins

cleanup[2] removing posix

cleanup[2] removing encodings

destroy encodings

cleanup[2] removing _osx_support

destroy _osx_support

cleanup[2] removing sys

cleanup[2] removing copyreg

cleanup[2] removing sre_compile

cleanup[2] removing os.path

cleanup[2] removing main

destroy main

cleanup[2] removing sre_constants

destroy sre_constants

cleanup[2] removing _imp

cleanup[2] removing _weakrefset

destroy _weakrefset

cleanup[2] removing posixpath

cleanup[2] removing encodings.aliases

cleanup[2] removing marshal

cleanup[2] removing genericpath

cleanup[2] removing io

destroy io

cleanup[2] removing _sitebuiltins

cleanup[2] removing _sre

cleanup[2] removing _bootlocale

destroy _bootlocale

cleanup[2] removing _thread

cleanup[2] removing _weakref

cleanup[2] removing _frozen_importlib_external

cleanup[2] removing _collections_abc

destroy _collections_abc

cleanup[2] removing os

cleanup[2] removing sysconfig

destroy sysconfig

cleanup[2] removing errno

cleanup[2] removing _io

cleanup[2] removing stat

cleanup[2] removing _codecs

cleanup[2] removing _sysconfigdata

destroy _sysconfigdata

cleanup[2] removing _signal

cleanup[2] removing codecs

cleanup[2] removing encodings.utf_8

cleanup[2] removing re

cleanup[2] removing abc

destroy abc

cleanup[2] removing _locale

cleanup[2] removing _warnings

cleanup[2] removing zipimport

cleanup[2] removing _stat

cleanup[2] removing _frozen_importlib

cleanup[2] removing sre_parse

destroy zipimport

destroy _signal

destroy errno

destroy posixpath

destroy _stat

destroy genericpath

destroy stat

destroy re

destroy copyreg

destroy sre_compile

destroy sre_parse

destroy _sre

destroy _locale

destroy os

destroy _sitebuiltins

cleanup[3] wiping encodings.latin_1

cleanup[3] wiping posix

cleanup[3] wiping _imp

cleanup[3] wiping encodings.aliases

cleanup[3] wiping marshal

cleanup[3] wiping _thread

cleanup[3] wiping _weakref

cleanup[3] wiping _frozen_importlib_external

destroy posix

destroy marshal

cleanup[3] wiping _io

destroy io

cleanup[3] wiping _codecs

cleanup[3] wiping codecs

cleanup[3] wiping encodings.utf_8

cleanup[3] wiping _warnings

cleanup[3] wiping _frozen_importlib

destroy _warnings

destroy _frozen_importlib_external

destroy _weakref

destroy _thread

destroy _imp

cleanup[3] wiping sys

cleanup[3] wiping builtins

destroy _frozen_importlib



This video can help you solving your question :)
By: admin