Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.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 重新安装Mac OS 10.7后Django开发环境已损坏_Python_Django_Osx Lion_Virtualenv_Mysql Python - Fatal编程技术网

Python 重新安装Mac OS 10.7后Django开发环境已损坏

Python 重新安装Mac OS 10.7后Django开发环境已损坏,python,django,osx-lion,virtualenv,mysql-python,Python,Django,Osx Lion,Virtualenv,Mysql Python,最近,我的硬盘遇到了问题,并使用磁盘实用程序重新安装了Mac OS 10.7 Lion。 当我运行Django应用程序时,出现以下错误: ################ BEGIN ERRORS ################## Traceback (most recent call last): File "manage.py", line 17, in <module> execute_manager(settings) File "/Users/my_u

最近,我的硬盘遇到了问题,并使用磁盘实用程序重新安装了Mac OS 10.7 Lion。 当我运行Django应用程序时,出现以下错误:

################ BEGIN ERRORS ##################
Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    execute_manager(settings)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/core/management/base.py", line 209, in execute
    translation.activate('en-us')

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 100, in activate
    return _trans.activate(language)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 202, in activate
    _active.value = translation(language)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 185, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 162, in _fetch
    app = import_module(appname)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 3, in <module>
    from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/contrib/admin/helpers.py", line 3, in <module>
    from django.contrib.admin.util import (flatten_fieldsets, lookup_field,

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/contrib/admin/util.py", line 1, in <module>
    from django.db import models

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/db/__init__.py", line 78, in <module>
    connection = connections[DEFAULT_DB_ALIAS]

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/db/utils.py", line 33, in load_backend
    return import_module('.base', backend_name)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)

  File "/Users/my_username/Sites/python_projects/my_project/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
################ END ERRORS ##################
我的注意力集中在使用各种方法重新安装mysql-python连接器上,例如在互联网上找到的方法。不走运。所有重新安装mysql python的尝试都会失败,并出现许多错误。不知道为什么我需要重新安装mysql-python

echo $PATH
-----------
/Users/my_username/Sites/python_projects/my_project/bin:/opt/subversion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/local/mysql/bin:/Developer/usr/bin


echo $PYTHONPATH
-----------------
/Users/my_username/lib/python
问题:

有关于如何修复的提示吗? 关于我重新安装Mac OS 10.7时发生的变化/损坏,有什么线索吗? 感谢您的帮助。谢谢大家!

尝试构建/编译mysql python时附加的错误消息:

您有两个选择:

使用
要完成这两项任务,您需要先安装xcode,可以从mac app store免费获得,但需要4GB+下载。

如果您可以编辑您的问题,将您在尝试安装mysql python时遇到的错误包括在内,这会有所帮助。看这个:。谢谢@NathanJones。我在尝试安装mysql python时添加了错误。我花了几天时间解决这个问题,但还没有解决它。从内存中,我确实使用easy_install-U python mysql安装了mysql python,但在尝试使用django时,仍然给我留下了一个image not found错误。我知道有些人已经成功了,所以这是可以做到的!谢谢@burhan。在升级到Lion之前,它在没有macports的情况下工作。将查看手动安装步骤。
echo $PATH
-----------
/Users/my_username/Sites/python_projects/my_project/bin:/opt/subversion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/local/mysql/bin:/Developer/usr/bin


echo $PYTHONPATH
-----------------
/Users/my_username/lib/python
% pwd
/Users/my_username/MySQL-python-1.2.3b2

% ARCHFLAGS='-arch x86_64' python setup.py build
--------------------------------------------------

running build

running build_py

copying MySQLdb/release.py -> build/lib.macosx-10.7-x86_64-2.7/MySQLdb

running build_ext

building '_mysql' extension

llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,3,'beta',2) -D__version__=1.2.3b2 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.7-x86_64-2.7/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch i386

In file included from _mysql.c:29:

pymemcompat.h:10:20: error: Python.h: No such file or directory

_mysql.c:30:26: error: structmember.h: No such file or directory

In file included from _mysql.c:37:

/usr/local/mysql/include/mysql.h:47:23: error: sys/types.h: No such file or directory

In file included from /usr/local/mysql/include/mysql.h:72,

                 from _mysql.c:37:

/usr/local/mysql/include/mysql_com.h:455: error: expected declaration specifiers or '...' before 'size_t'

/usr/local/mysql/include/mysql_com.h:457: error: expected declaration specifiers or '...' before 'size_t'

/usr/local/mysql/include/mysql_com.h:459: error: expected declaration specifiers or '...' before 'size_t'

/usr/local/mysql/include/mysql_com.h:460: error: expected declaration specifiers or '...' before 'size_t'

/usr/local/mysql/include/mysql_com.h:461: error: expected declaration specifiers or '...' before 'size_t'

In file included from /usr/local/mysql/include/typelib.h:20,

                 from /usr/local/mysql/include/mysql.h:131,

                 from _mysql.c:37:

/usr/local/mysql/include/my_alloc.h:44: error: expected specifier-qualifier-list before 'size_t'

_mysql.c:61: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

_mysql.c:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

_mysql.c:63: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

[ OMITTED QUITE A NUMBER OF LINES TO PROTECT THE INNOCENT ]

_mysql.c:2533: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_mysql_ConnectionObject_Type'

_mysql.c:2617: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_mysql_ResultObject_Type'

_mysql.c:2703: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_mysql_methods'

_mysql.c:2775: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

_mysql.c:2807: warning: return type defaults to 'int'

_mysql.c: In function 'DL_EXPORT':

_mysql.c:2807: error: expected declaration specifiers before 'init_mysql'

_mysql.c:2885: error: expected '{' at end of input

error: command 'llvm-gcc-4.2' failed with exit status 1