This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Python 3 import error after installation
Type: behavior Stage: resolved
Components: Installation, macOS Versions: Python 3.5
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Richard Penman, ned.deily, ronaldoussoren, steven.daprano, zach.ware
Priority: normal Keywords:

Created on 2016-05-23 10:10 by Richard Penman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (6)
msg266133 - (view) Author: Richard Penman (Richard Penman) Date: 2016-05-23 10:10
I installed latest release ( on OSX and get this error:

$ python3
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.

Also tried installing via brew and got same error.
msg266134 - (view) Author: Richard Penman (Richard Penman) Date: 2016-05-23 10:14
The full error log:

$ python3
Failed to import the site module
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/", line 75, in <module>
  File "/usr/local/lib/python2.7/site-packages/", line 23, in __boot
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 563, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 549, in main
    known_paths = addusersitepackages(known_paths)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 281, in addusersitepackages
    user_site = getusersitepackages()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 257, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 247, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 582, in get_config_var
    return get_config_vars().get(name)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 561, in get_config_vars
    import _osx_support
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 4, in <module>
    import re
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 335, in <module>
    import copyreg
  File "/usr/local/lib/python2.7/site-packages/copyreg/", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.

What needs to be changed to avoid importing Python 2 modules?
msg266136 - (view) Author: Richard Penman (Richard Penman) Date: 2016-05-23 10:19
Apparently "The PYTHONPATH variable is used by all versions of Python 2 and Python 3, so you should not permanently configure this variable unless it only includes code that is compatible with all of your installed Python versions."

That seems crazy...
msg266141 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2016-05-23 12:49
It looks like your Python 3 is somehow using your Python 2 site directory. What does your PYTHONPATH contain?

Try running this:

python3 -E -S -c "import sys; print(sys.path)"

and see what it says.
msg266161 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-05-23 16:19
> That seems crazy...

What's crazy about it?  There are very very few legitimate situations where you need to permanently set any PYTHON* variable, particularly PYTHONPATH and PYTHONHOME.  Adding site-packages to sys.path via PYTHONPATH is completely unnecessary anyway since will do that for you in a much safer manner.

This looks like a local configuration issue; closing.
msg266162 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-05-23 16:24
To add to Zach's comment, there have been extended discussions in the past about whether there should be a separate set of environment variables for Python 3 vs Python 2 interpreters; see, for instance, Issue2375 and  In the latter, Guido pronounced on the matter: no separate values for PYTHONPATH since PYTHONPATH is not intended to be used on permanent basis.  Either install distribution packages normally (to site-packages) or use a virtual environment.
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71277
2016-05-23 16:24:17ned.deilysetmessages: + msg266162
2016-05-23 16:19:47zach.waresetstatus: open -> closed

nosy: + zach.ware
messages: + msg266161

resolution: not a bug
stage: resolved
2016-05-23 12:49:41steven.dapranosettype: crash -> behavior

messages: + msg266141
nosy: + steven.daprano
2016-05-23 10:19:02Richard Penmansetmessages: + msg266136
2016-05-23 10:14:18Richard Penmansetmessages: + msg266134
2016-05-23 10:10:49Richard Penmancreate