python3解释器执行 not 1 and 1的结果为_如何在我的虚拟环境中使用Python 3(3.5)作为默认的解释器?...

I ran into problems when I installed Python 3.5 on Mac. I wanted to use Python 3.5 as the interpreter when I ran my Django development server. I got this issue when I tried it (I know I must install a virtualenv, read below):

$ python3 manage.py runserver

Traceback (most recent call last):

File "manage.py", line 7, in

from mezzanine.utils.conf import real_project_name

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Mezzanine-4.0.1-py3.5.egg/mezzanine/utils/conf.py", line 7, in

from django.conf import global_settings as defaults

ImportError: No module named 'django'

The first was when I tried installing pip packages it installed by default on the Python 2.7 in my virtual environment:

pip install django==1.9rc2

Collecting django==1.9rc2

Downloading Django-1.9rc2-py2.py3-none-any.whl (6.4MB)

100% |████████████████████████████████| 6.4MB 66kB/s

Installing collected packages: django

Successfully installed django-1.9rc2

I use Django so I tried also install a virtual environment for the first time. First I tried it with pip, but that didn't work.

So how do I setup so that my Python3.5 is the default usage when using Python interpreter and in my virtual environment? I can't figure this out or I have done something wrong in my process.

Edit:

Thanks for the answer and comment. I tried with the both solutions and the same error persisted. See output below:

$ virtualenv -p /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 Django/

Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5

Traceback (most recent call last):

File "/Library/Python/2.7/site-packages/virtualenv.py", line 14, in

import shutil

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 10, in

import fnmatch

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py", line 15, in

import functools

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py", line 21, in

from collections import namedtuple

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 16, in

from reprlib import recursive_repr as _recursive_repr

File "/Library/Python/2.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.

My virtualenv version: 13.1.2

解决方案

Your error is related to a known virtualenv bug regarding python-future and mixing up the 2.7 and 3.x module paths, the solution is to downgrade virtualenv to a version < 12.04, 12.0.2 is suggested in the link.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值