LINUX.ORG.RU

Nginx + uWSGI + virtualenv + Django на Debian

 , , ,


0

1

Добрый день. неделю уже сижу изучаю как установить связку Nginx + uWSGI + virtualenv + Django на Debian python 2.7.13 Debian 8. Тестовый сайт запустился без проблем

 def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return ["Hello World"] # python2

Далее в эту же директорию загрузил новый копию другого сайта на python 2.7.12. Активирую режим виртуальности

 source bin/activate 

Запускаю сайт

 python manage.py runserver 0.0.0.0:8000 

и у меня возникают ошибки

(uwsgi-tutorial)root@velkom-promo:/usr/src/velkompromo/velkompromo# python manage.py runserver 0.0.0.0:8000
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/core/management/__init__.py", line 307, in execute
    settings.INSTALLED_APPS
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named velkompromo.settings

Господа, помогите узнать, что я сделал не так? что поправить?

Очевидно в этом

ImportError: No module named velkompromo.settings

Либо не правильно импортируешь (не из того каталога, например), либо модуля у тебя просто нет

Dred ★★★★★ ()
Ответ на: комментарий от Dred

я исправил на beacon.settings. ПОдумал - это должна быть директория. глупо. Но в итоге я поставил кучу пакетов дополнительно. половину сайт принял. а Вот на одном пакете flat не хочет принимать. при команде pip list

root@velkom-promo:/usr/src/velkompromo/uwsgi-tutorial/bin# pip2.7 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
aldryn-sites (0.5.8)
bambu-sites (0.1)
chardet (2.3.0)
defusedxml (0.4.1)
distribute (0.7.3)
dj-database-url (0.4.2)
Django (1.9.13)
django-account-helper (0.1.5)
django-admin-backend (0.6.0)
django-appconf (1.0.2)
django-dictmessages (1.0.0)
django-ecstatic (0.2.2)
django-filebrowser (3.7.2)
django-floppyforms (1.7.0)
django-grappelli (2.8.3)
django-icons-backtopixel (1.0)
django-icons-icojoy (1.0)
django-icons-icojoy-pointers (1.0)
django-icons-onebit (1.0)
django-icons-splashyicons (1.0)
django-icons-tango (1.0)
django-icons-twitterjoy (1.0)
django-icons-web-control (1.0)
django-redisession (0.3.1)
django-superform (0.3.1)
django-tinymce-4 (0.0.18)
django-viewset (0.1.1)
docutils (0.12)
Flat (0.2)
Pillow (2.6.1)
pip (9.0.1)
Pygments (2.0.1)
python-apt (0.9.3.12)
python-debian (0.1.27)
python-debianbts (1.11)
pytz (2017.2)
reportbug (6.6.3)
roman (2.0.0)
setuptools (5.5.1)
six (1.8.0)
SOAPpy (0.12.22)
uWSGI (2.0.15)
wstools (0.4.3)
YURL (0.13)

после запуска снова, выдает ошибку такую

(uwsgi-tutorial)root@velkom-promo:/usr/src/velkompromo/velkompromo# python manage.py runserver 0.0.0.0:8000
Unhandled exception in thread started by <function wrapper at 0x7f8f38e578c0>
Traceback (most recent call last):
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named flat

rayden8 ()
Ответ на: комментарий от rayden8

в логах pip.log

/usr/src/velkompromo/uwsgi-tutorial/bin/pip2.7 run on Fri Jul 14 14:59:06 2017
Downloading/unpacking flat
  Getting page https://pypi.python.org/simple/flat/
  URLs to search for versions for flat:
  * https://pypi.python.org/simple/flat/
  Analyzing links from page https://pypi.python.org/simple/flat/
    Found link https://pypi.python.org/packages/07/43/9d1f4ef10fad83fec5b8f431cf200f92f0ad10874382df7e7a4908b88040/Flat-0.2.tar.gz#md5=b5425332de6419fb6e31d643c5b0d4d2 (from https://pypi.python.org/simple/flat/), version:
    Found link https://pypi.python.org/packages/dc/b8/632a9e9db6d75fe93165d09e687d972ae1babe1a785b09e7e728b7e2773f/Flat-0.1.tar.gz#md5=c73d85ba42e4506eb6ef85d81d78aca0 (from https://pypi.python.org/simple/flat/), version:
  Using version 0.2 (newest of versions: 0.2, 0.1)
  Downloading from URL https://pypi.python.org/packages/07/43/9d1f4ef10fad83fec5b8f431cf200f92f0ad10874382df7e7a4908b88040/Flat-0.2.tar.gz#md5=b5425332de6419fb6e31d643c5b0d4d2 (from https://pypi.python.org/simple/flat/)
  Running setup.py (path:/tmp/pip-build-dnhuPC/flat/setup.py) egg_info for package flat
    running egg_info
    creating pip-egg-info/Flat.egg-info
    writing pip-egg-info/Flat.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/Flat.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/Flat.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/Flat.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
....
    reading manifest file 'pip-egg-info/Flat.egg-info/SOURCES.txt'
    writing manifest file 'pip-egg-info/Flat.egg-info/SOURCES.txt'
  Source in /tmp/pip-build-dnhuPC/flat has version 0.2, which satisfies requirement flat
Installing collected packages: flat
  Running setup.py install for flat
    Running command /usr/src/velkompromo/uwsgi-tutorial/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-dnhuPC/flat/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/flat
    copying flat/otf.py -> build/lib/flat
    copying flat/stl.py -> build/lib/flat
    copying flat/font.py -> build/lib/flat
    copying flat/path.py -> build/lib/flat
    copying flat/image.py -> build/lib/flat
    copying flat/extra.py -> build/lib/flat
    copying flat/jpeg.py -> build/lib/flat
    copying flat/png.py -> build/lib/flat
    copying flat/color.py -> build/lib/flat
    copying flat/misc.py -> build/lib/flat
    copying flat/even.py -> build/lib/flat
    copying flat/shape.py -> build/lib/flat
    copying flat/bezier.py -> build/lib/flat
    copying flat/pdf.py -> build/lib/flat
    copying flat/document.py -> build/lib/flat
    copying flat/text.py -> build/lib/flat
    copying flat/scene.py -> build/lib/flat
    copying flat/cff.py -> build/lib/flat
    copying flat/svg.py -> build/lib/flat
    copying flat/polynomial.py -> build/lib/flat
    copying flat/__init__.py -> build/lib/flat
    copying flat/command.py -> build/lib/flat
    copying flat/rasterizer.py -> build/lib/flat
    copying flat/mesh.py -> build/lib/flat
    copying flat/readable.py -> build/lib/flat
    copying flat/group.py -> build/lib/flat
    running install_lib



rayden8 ()
Ответ на: комментарий от rayden8
Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-dnhuPC/flat/setup.py", line 34, in <module>
        'Topic :: Text Processing :: Fonts'])
      File "/usr/local/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/lib/python2.7/distutils/command/install.py", line 575, in run
        self.run_command(cmd_name)
      File "/usr/local/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python2.7/distutils/dist.py", line 971, in run_command
        cmd_obj.ensure_finalized()
      File "/usr/local/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
        self.finalize_options()
      File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/setuptools/command/install_lib.py", line 16, in finalize_options
        self.set_undefined_options('install',('install_layout','install_layout'))
      File "/usr/local/lib/python2.7/distutils/cmd.py", line 302, in set_undefined_options
        getattr(src_cmd_obj, src_option))
      File "/usr/local/lib/python2.7/distutils/cmd.py", line 105, in __getattr__
        raise AttributeError, attr
    AttributeError: install_layout
    Complete output from command /usr/src/velkompromo/uwsgi-tutorial/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-dnhuPC/flat/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().
    running install

running build

running build_py

creating build

creating build/lib

creating build/lib/flat

copying flat/otf.py -> build/lib/flat

copying flat/stl.py -> build/lib/flat

copying flat/font.py -> build/lib/flat

copying flat/path.py -> build/lib/flat

copying flat/image.py -> build/lib/flat

copying flat/extra.py -> build/lib/flat
copying flat/jpeg.py -> build/lib/flat

copying flat/png.py -> build/lib/flat

copying flat/color.py -> build/lib/flat

copying flat/misc.py -> build/lib/flat

copying flat/even.py -> build/lib/flat

copying flat/shape.py -> build/lib/flat

copying flat/bezier.py -> build/lib/flat

copying flat/pdf.py -> build/lib/flat

copying flat/document.py -> build/lib/flat

copying flat/text.py -> build/lib/flat

copying flat/scene.py -> build/lib/flat

copying flat/cff.py -> build/lib/flat

copying flat/svg.py -> build/lib/flat

copying flat/polynomial.py -> build/lib/flat

copying flat/__init__.py -> build/lib/flat

copying flat/command.py -> build/lib/flat

copying flat/rasterizer.py -> build/lib/flat

copying flat/mesh.py -> build/lib/flat

copying flat/readable.py -> build/lib/flat

copying flat/group.py -> build/lib/flat

running install_lib

Traceback (most recent call last):

  File "<string>", line 1, in <module>
File "/tmp/pip-build-dnhuPC/flat/setup.py", line 34, in <module>

    'Topic :: Text Processing :: Fonts'])

  File "/usr/local/lib/python2.7/distutils/core.py", line 151, in setup

    dist.run_commands()

  File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run

    return orig.install.run(self)

  File "/usr/local/lib/python2.7/distutils/command/install.py", line 575, in run

    self.run_command(cmd_name)

  File "/usr/local/lib/python2.7/distutils/cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "/usr/local/lib/python2.7/distutils/dist.py", line 971, in run_command

    cmd_obj.ensure_finalized()

  File "/usr/local/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized

    self.finalize_options()

  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/setuptools/command/install_lib.py", line 16, in finalize_options

    self.set_undefined_options('install',('install_layout','install_layout'))

  File "/usr/local/lib/python2.7/distutils/cmd.py", line 302, in set_undefined_options

    getattr(src_cmd_obj, src_option))

  File "/usr/local/lib/python2.7/distutils/cmd.py", line 105, in __getattr__

    raise AttributeError, attr

AttributeError: install_layout
Cleaning up...
Command /usr/src/velkompromo/uwsgi-tutorial/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-dnhuPC/flat/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __
file__, 'exec'))" install --record /tmp/pip-RF6SVh-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/src/velkompromo/uwsgi-tutorial/include/site/python2.7 failed with error code
 1 in /tmp/pip-build-dnhuPC/flat
Exception information:
Traceback (most recent call last):
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/pip/commands/install.py", line 295, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/pip/req.py", line 707, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/src/velkompromo/uwsgi-tutorial/lib/python2.7/site-packages/pip/util.py", line 716, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/src/velkompromo/uwsgi-tutorial/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-dnhuPC/flat/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replac
e('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-RF6SVh-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/src/velkompromo/uwsgi-tutorial/include/site/python2.7 fai
led with error code 1 in /tmp/pip-build-dnhuPC/flat
rayden8 ()
Ответ на: комментарий от rayden8

Я правильно понимаю, что на платформе линукс ставлю Pip install в дальнейшем не устанавливается в виртуальной среде ? и там надо ставить отдельно? но возникают ошибки при установке любого пакета

Command /usr/src/velkompromo/uwsgi-tutorial/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-d_S_Vo/FoLiA-Linguistic-Annotation-Tool/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ey1aG9-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/src/velkompromo/uwsgi-tutorial/include/site/python2.7 failed with error code 1 in /tmp/pip-build-d_S_Vo/FoLiA-Linguistic-Annotation-Tool
Storing debug log for failure in /root/.pip/pip.log

Это последняя часть логов выше. Что он от меня хочет? как - то можно импортировать в виртуальную часть из не виртуальной?

rayden8 ()
Ответ на: комментарий от rayden8

Вот читаю и половину твоих мыслей не могу понять.

Если правильно тебя понял, то:

1. Создаешь виртуальное окружение.

2. Активируешь его.

3. Делаешь все что надо с pip в этом виртуальном окружении.

4. Настраиваешь и запускаешь сервер.

gruy ★★★★ ()

Попробуй для начала без virtualenv поднять. Потом разберешься что к чему и сделаешь с virtualenv.

bitfroster ★★ ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.