python not 3_“此程序包不应在Python 3上访问”。运行python3时

I was trying to use virtualenv to switch between python versions before learning that I could use both python and python3 on my Mac.

I was able to fix my python 2.7 version so that still works fine however, now when I run python3, I get this error:

Failed to import the site module

Traceback (most recent call last):

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 544, in

main()

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 530, in main

known_paths = addusersitepackages(known_paths)

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 282, in addusersitepackages

user_site = getusersitepackages()

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 258, in getusersitepackages

user_base = getuserbase() # this will also set USER_BASE

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 248, in getuserbase

USER_BASE = get_config_var('userbase')

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sysconfig.py", line 601, in get_config_var

return get_config_vars().get(name)

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sysconfig.py", line 580, in get_config_vars

import _osx_support

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_osx_support.py", line 4, in

import re

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 125, in

import functools

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/functools.py", line 21, in

from collections import namedtuple

File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/collections/__init__.py", line 32, in

from reprlib import recursive_repr as _recursive_repr

File "/usr/local/lib/python2.7/site-packages/reprlib/__init__.py", line 7, in

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.

I've looked online for this error but most of the conversation was on fixing up the patch and then upgrading virtualenv. However, this still doesn't fix my issue.

python3 -V: Python 3.6.0

virtualenv --version: 15.1.0

env | egrep -i 'python|virtualenv': PYTHONPATH=/usr/local/lib/python2.7/site-packages:

解决方案

Your environment contains PYTHONPATH=/usr/local/lib/python2.7/site-packages

This doesn't work with Python 3 for obvious reasons. To remove it:

unset PYTHONPATH

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值