Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在我的虚拟环境中使用Python 3(3.5)作为默认解释器?_Python_Django_Python 3.x_Virtualenv - Fatal编程技术网

如何在我的虚拟环境中使用Python 3(3.5)作为默认解释器?

如何在我的虚拟环境中使用Python 3(3.5)作为默认解释器?,python,django,python-3.x,virtualenv,Python,Django,Python 3.x,Virtualenv,我在Mac上安装Python3.5时遇到了问题。当我运行Django开发服务器时,我想使用Python 3.5作为解释器。我在尝试时遇到了这个问题(我知道我必须安装virtualenv,如下所示): 我使用Django,所以我第一次尝试安装虚拟环境。首先我用皮普试过,但没用 那么,在使用Python解释器和虚拟环境时,如何设置使Python3.5成为默认用法呢?我无法理解这一点,或者在我的过程中我做错了什么 编辑: 谢谢你的回答和评论。我尝试了两种解决方案,但同样的错误依然存在。见下面的输出:

我在Mac上安装Python3.5时遇到了问题。当我运行Django开发服务器时,我想使用Python 3.5作为解释器。我在尝试时遇到了这个问题(我知道我必须安装virtualenv,如下所示):

我使用Django,所以我第一次尝试安装虚拟环境。首先我用皮普试过,但没用

那么,在使用Python解释器和虚拟环境时,如何设置使Python3.5成为默认用法呢?我无法理解这一点,或者在我的过程中我做错了什么

编辑:

谢谢你的回答和评论。我尝试了两种解决方案,但同样的错误依然存在。见下面的输出:

$ 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 <module>
    import shutil
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 10, in <module>
    import fnmatch
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py", line 15, in <module>
    import functools
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py", line 21, in <module>
    from collections import namedtuple
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 16, in <module>
    from reprlib import recursive_repr as _recursive_repr
  File "/Library/Python/2.7/site-packages/reprlib/__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.
$virtualenv-p/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 Django/
使用解释器/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5运行virtualenv
回溯(最近一次呼叫最后一次):
文件“/Library/Python/2.7/site packages/virtualenv.py”,第14行,在
进口舒蒂尔
文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py”,第10行,在
导入fnmatch
文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py”,第15行,在
导入功能工具
文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py”,第21行,在
从集合导入namedtuple
文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init___.py”,第16行,在
从reprlib导入递归的_repr作为_递归的_repr
文件“/Library/Python/2.7/site-packages/reprlib/_-init__uuu.py”,第7行,在
raise ImportError('在Python 3上不应访问此包。'
ImportError:在Python 3上不应访问此包。可能是您试图从Python future src文件夹运行,或者是您的Python future安装已损坏。

我的virtualenv版本:13.1.2

首先,如果要使用多个版本的python,则必须使用Virtual Env。然后使用以下命令创建virtualenv,使其使用python 3.5作为默认环境:

          virtualenv -p python3 envname

然后在virtualenv中安装django。激活virtualenv后,您的错误与已知的关于python未来的
virtualenv
virtualenv
有关,并且混合了2.7和3.x模块路径,解决方案是将
virtualenv
降级到<12.04版本,链接中建议
12.0.2

t当创建一个新的virtualenv
$virtualenv-p/usr/bin/python3.5
取自@qasimalbaqali:我试过了,检查我问题中的输出。你真的激活了你的virtualenv吗?你使用的是什么版本的virtualenv?@PadraicCunningham他正在尝试创建一个virtualenv,所以他实际上无法激活我t在创建python 3.5虚拟环境之前。@PadraicCunningham:是的,它对python 2.7有效。但后来我再试了一次,因为我想要python 3.5,而现在我甚至不能创建虚拟环境。
$ 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 <module>
    import shutil
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 10, in <module>
    import fnmatch
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py", line 15, in <module>
    import functools
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py", line 21, in <module>
    from collections import namedtuple
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 16, in <module>
    from reprlib import recursive_repr as _recursive_repr
  File "/Library/Python/2.7/site-packages/reprlib/__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.
          virtualenv -p python3 envname