django无法找到git

时间:2013-11-09 20:57:47

标签: django git windows-7 environment-variables

我正在尝试在我的Windows 7分区上启动Django开发,并且我发现每当我运行Django命令时,我得到:

'git' is not recognized as an internal or external command,
operable program or batch file.

连续3-4次但是命令似乎执行得很好。虽然它似乎没有影响命令的执行,但我不喜欢每次做某事时都会抛出错误,让我感到紧张(而且很可能我错过了哪些错误)。我尝试将git添加到我的环境变量中,但它似乎不起作用,这是当前的PATH值。

 ;C:\Chocolatey\bin;C:\tools\mysql\current\bin;C:\Program Files (x86)\Git\bin

欢迎任何其他建议尝试。我正在使用Windows 7和最新版本的Python,Django和Git(今天刚刚下载)。

编辑:我再次运行命令以回应您的一些评论(感谢那些顺便说一句)。这是python manage.py runserver

的输出

致命:不是git存储库(或任何父目录):。git 致命的:不是git存储库(或任何父目录):。git Traceback(最近一次调用最后一次):   文件“C:\ Python33 \ lib \ site-packages \ django \ db \ backends \ mysql \ base.py”,第14行,in     将MySQLdb导入为数据库 ImportError:没有名为'MySQLdb'的模块

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 416, in execute_from_command_line
    utility.execute()
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 408, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python33\lib\site-packages\django\core\management\base.py", line 244, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python33\lib\site-packages\django\core\management\base.py", line 286, in execute
    translation.activate('en-us')
  File "C:\Python33\lib\site-packages\django\utils\translation\__init__.py", line 142, in activate
    return _trans.activate(language)
  File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 218, in activate
    _active.value = translation(language)
  File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 201, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 183, in _fetch
    app = import_module(appname)
  File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1586, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1024, in load_module
  File "<frozen importlib._bootstrap>", line 1005, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 870, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "C:\Python33\lib\site-packages\django\contrib\admin\__init__.py", line 7, in <module>
    from django.contrib.admin.sites import AdminSite, site
  File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py", line 4, in <module>
    from django.contrib.admin.forms import AdminAuthenticationForm
  File "C:\Python33\lib\site-packages\django\contrib\admin\forms.py", line 6, in <module>
    from django.contrib.auth.forms import AuthenticationForm
  File "C:\Python33\lib\site-packages\django\contrib\auth\forms.py", line 16, in <module>
    from django.contrib.auth.models import User
  File "C:\Python33\lib\site-packages\django\contrib\auth\models.py", line 40, in <module>
    class Permission(models.Model):
  File "C:\Python33\lib\site-packages\django\db\models\base.py", line 108, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "C:\Python33\lib\site-packages\django\db\models\base.py", line 291, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Python33\lib\site-packages\django\db\models\options.py", line 141, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "C:\Python33\lib\site-packages\django\db\__init__.py", line 39, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Python33\lib\site-packages\django\db\utils.py", line 192, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Python33\lib\site-packages\django\db\utils.py", line 107, in load_backend
    return import_module('%s.base' % backend_name)
  File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

这是python manage.py syncdb

的输出
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 14, in <module>
    import MySQLdb as Database
ImportError: No module named 'MySQLdb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 416, in execute_from_command_line
    utility.execute()
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 408, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python33\lib\site-packages\django\core\management\base.py", line 244, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python33\lib\site-packages\django\core\management\base.py", line 286, in execute
    translation.activate('en-us')
  File "C:\Python33\lib\site-packages\django\utils\translation\__init__.py", line 142, in activate
    return _trans.activate(language)
  File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 218, in activate
    _active.value = translation(language)
  File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 201, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 183, in _fetch
    app = import_module(appname)
  File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1586, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1024, in load_module
  File "<frozen importlib._bootstrap>", line 1005, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 870, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "C:\Python33\lib\site-packages\django\contrib\admin\__init__.py", line 7, in <module>
    from django.contrib.admin.sites import AdminSite, site
  File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py", line 4, in <module>
    from django.contrib.admin.forms import AdminAuthenticationForm
  File "C:\Python33\lib\site-packages\django\contrib\admin\forms.py", line 6, in <module>
    from django.contrib.auth.forms import AuthenticationForm
  File "C:\Python33\lib\site-packages\django\contrib\auth\forms.py", line 16, in <module>
    from django.contrib.auth.models import User
  File "C:\Python33\lib\site-packages\django\contrib\auth\models.py", line 40, in <module>
    class Permission(models.Model):
  File "C:\Python33\lib\site-packages\django\db\models\base.py", line 108, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "C:\Python33\lib\site-packages\django\db\models\base.py", line 291, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Python33\lib\site-packages\django\db\models\options.py", line 141, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "C:\Python33\lib\site-packages\django\db\__init__.py", line 39, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Python33\lib\site-packages\django\db\utils.py", line 192, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Python33\lib\site-packages\django\db\utils.py", line 107, in load_backend
    return import_module('%s.base' % backend_name)
  File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

似乎是缺少MySQLdb的结果。有没有人有这个模块的链接?我在Pypi上找不到任何关于的确切,我不确定它正在寻找哪一个。

1 个答案:

答案 0 :(得分:1)

你有可能用试图启动git的东西覆盖你的“manage.py”吗?您的manage.py应如下所示:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourapp.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

或者你的settings.py中有“git”commant吗?

错误日志后编辑: 您是否安装了MySQL-python包(请参阅https://docs.djangoproject.com/en/dev/topics/install/#get-your-database-running上的文档)和MySQLdb(请参阅https://docs.djangoproject.com/en/dev/ref/databases/#mysqldb)?使用MySQL时都需要这两个。

如果是,转换到sqlite数据库时会得到相同的结果吗?