Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.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 Django回溯错误:没有名为';报告';_Python_Django - Fatal编程技术网

Python Django回溯错误:没有名为';报告';

Python Django回溯错误:没有名为';报告';,python,django,Python,Django,直到今天,我一直在使用django完美无问题。它给了我一个现有项目的错误,但我最近尝试创建一个新项目,我仍然得到相同的错误。 我使用的是Ubuntu14.04、Django1.7,我使用的是virtualenv和Python3(尽管我也尝试过使用python2环境) 我得到这个错误: ubuntuuser@computer:~/tmp$ ubuntuuser@computer:~/tmp$ mkvirtualenv djerror New python executable in djerro

直到今天,我一直在使用django完美无问题。它给了我一个现有项目的错误,但我最近尝试创建一个新项目,我仍然得到相同的错误。 我使用的是Ubuntu14.04、Django1.7,我使用的是virtualenv和Python3(尽管我也尝试过使用python2环境)

我得到这个错误:

ubuntuuser@computer:~/tmp$ 
ubuntuuser@computer:~/tmp$ mkvirtualenv djerror
New python executable in djerror/bin/python
Installing setuptools, pip...done.
cd (djerror)ubuntuuser@computer:~/tmp$ cd borrar/
bin/     borrar/  include/ lib/     local/   
(djerror)ubuntuuser@computer:~/tmp$ django-admin.py startproject djerror
(djerror)ubuntuuser@computer:~/tmp$ cd djerror/
(djerror)ubuntuuser@computer:~/tmp/djerror$ ls
djerror  manage.py
(djerror)ubuntuuser@computer:~/tmp/djerror$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 1, in <module>
    import collections
  File "/usr/local/lib/python3.4/collections/__init__.py", line 17, in <module>
    from reprlib import recursive_repr as _recursive_repr
  File "/usr/local/lib/python2.7/dist-packages/reprlib.py", line 3, in <module>
    from repr import *
ImportError: No module named 'repr'
(djerror)ubuntuuser@computer:~/tmp/djerror$ 

我认为文件的其余部分没有被触动。

经过一些修改(尤其是在阅读了布兰登和丹尼尔的评论之后),我发现了这个问题

我在某个时候做错了什么,直到今天才引起问题。问题是python从python2路径加载了一些模块,从python3路径加载了其他模块

为了修复它,我做了以下操作:

  • 删除python3别名
    • 要正确执行此操作,您必须从/usr/bin/中rm python,然后将其指向python3 sim link
  • 清除python3并重新安装
  • 重新安装与python3相关的所有软件包,如pip和其他软件包

只有到那时,一切都正常了,尽管我可能做得太过火了,但我还是喜欢这样做,只是为了确定。

repr
是一个内置函数:但也有:这些回溯显示您同时从2.7和3.4库导入,这显然是错误的。你对你的PYTHONPATH环境变量做了什么吗?@Daniel Roseman:是的,可能是(正如我所说,我对这个很陌生),但不是最近。我会查出来的。@Brandon/Daniel我已经在我的bashrc中添加了一个编辑(实际上是昨天编辑的)。我很想听听你们对我做错了什么的看法。你们用了
python
的别名来使用python3,但你们的
PYTHONPATH
指向了python2.7的站点包。如果默认情况下要使用Python 3,则需要将
PYTHONPATH
更改为指向它的包,它在Ubuntu/Debian上位于
/usr/local/lib/python3.x/dist-packages
ubuntuuser@computer:~/tmp$ virtualenv djerror2
New python executable in djerror2/bin/python
Installing setuptools, pip...done.
ubuntuuser@computer:~/tmp$ cd djerror
ubuntuuser@computer:~/tmp/djerror$ cd ..
ubuntuuser@computer:~/tmp$ cd djerror2
ubuntuuser@computer:~/tmp/djerror2$ . bin/activate
(djerror2)ubuntuuser@computer:~/tmp/djerror2$ pip list
awsebcli (3.0.10)
cement (2.4.0)
Django (1.7.5)
django-bootstrap3 (5.1.1)
django-braces (1.4.0)
...
stevedore (1.2.0)
virtualenv (12.0.6)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.3.2)
(djerror2)ubuntuuser@computer:~/tmp/djerror2$ django-admin.py startproject anothertest
(djerror2)ubuntuuser@computer:~/tmp/djerror2$ cd anothertest/
(djerror2)ubuntuuser@computer:~/tmp/djerror2/anothertest$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 1, in <module>
    import collections
  File "/usr/local/lib/python3.4/collections/__init__.py", line 17, in <module>
    from reprlib import recursive_repr as _recursive_repr
  File "/usr/local/lib/python2.7/dist-packages/reprlib.py", line 3, in <module>
    from repr import *
ImportError: No module named 'repr'
(djerror2)ubuntuuser@computer:~/tmp/djerror2/anothertest$ 
alias python='python3'

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh