Python Django:ImportError:没有名为bootstrap3的模块

时间:2015-04-18 04:52:29

标签: python django python-2.7

我正在使用python 2.7,django.VERSION(1,7,7,'final',0)。 django-bootstrap3 5.3.1使用pip安装。 我仍然收到错误ImportError: No module named bootstrap3

ubuntu@ip-172-31-19-246:/opt$ python peace/src/manage.py runserver
Traceback (most recent call last):
  File "peace/src/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 123, in create
    import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named bootstrap3

我可以在python控制台中导入这个模块。

ubuntu@ip-172-31-19-246:/opt$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import  bootstrap3
>>> dir( bootstrap3)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__']
>>> print  bootstrap3.__path__
['/usr/local/lib/python2.7/dist-packages/bootstrap3']
>>>

1 个答案:

答案 0 :(得分:1)

您可以使用pip install virtualenv

安装virtualenv

从源

安装virtualenv
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ python virtualenv.py env

然后使用以下命令激活virtualenv

source env/bin/activate