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.
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 (https://www.python.org/downloads/release/python-351/) 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/site.py", line 75, in <module>
__boot()
File "/usr/local/lib/python2.7/site-packages/site.py", line 23, in __boot
loader.load_module('site')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site.py", line 563, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site.py", line 549, in main
known_paths = addusersitepackages(known_paths)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site.py", line 281, in addusersitepackages
user_site = getusersitepackages()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site.py", line 257, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site.py", line 247, in getuserbase
USER_BASE = get_config_var('userbase')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sysconfig.py", line 582, in get_config_var
return get_config_vars().get(name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sysconfig.py", line 561, in get_config_vars
import _osx_support
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_osx_support.py", line 4, in <module>
import re
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/re.py", line 335, in <module>
import copyreg
File "/usr/local/lib/python2.7/site-packages/copyreg/__init__.py", 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 site.py 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 http://comments.gmane.org/gmane.comp.python.devel/109797. 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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:31 | admin | set | github: 71277 |
| 2016年05月23日 16:24:17 | ned.deily | set | messages: + msg266162 |
| 2016年05月23日 16:19:47 | zach.ware | set | status: open -> closed nosy: + zach.ware messages: + msg266161 resolution: not a bug stage: resolved |
| 2016年05月23日 12:49:41 | steven.daprano | set | type: crash -> behavior messages: + msg266141 nosy: + steven.daprano |
| 2016年05月23日 10:19:02 | Richard Penman | set | messages: + msg266136 |
| 2016年05月23日 10:14:18 | Richard Penman | set | messages: + msg266134 |
| 2016年05月23日 10:10:49 | Richard Penman | create | |