estoy haciendo esto en FedoraError: No se pudo importar la configuración '' mysite.settings después de configurar virtualenv de Django
Problema:
(sandbox)[[email protected] mysite]# django-admin.py runserver
Error: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings
Configuración virtualenv
mkdir pythonenv # that's the /home/yeukhon/pythonenv/*.*
cd pythonenv
virtualenv --no-site-packages --distribute sandbox
Instalar Django
pip install -E sandbox django
# changing mode of /home/yeukhon/pythonenv/sandbox/bin/django-admin.py to 755
# Successfully installed django
en/home/yeukhon/pythonenv/caja de arena
bin include lib mysite
Bajo lib
You have /lib/python2.7/site-packages/django/*.*
crear el proyecto está bien
(sandbox)[[email protected] sandbox]# django-admin.py startproject mysite
# the path is now /home/yeukhon/pythonenv/sandbox/mysite/*.*
No se puede ejecutar el servidor
django-admin.py runserver
Error: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings
Python Shell bajo el cajón de arena (siguiendo esta guía: How to troubleshoot - ImportError: Could not import settings 'mysite.settings' when deploying django?)
(sandbox)[[email protected] mysite]# python
Python 2.7.2 (default, Oct 27 2011, 01:36:46)
[GCC 4.6.1 20111003 (Red Hat 4.6.1-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE']
'mysite.settings'
>>> os.path.exists('/home')
True
>>> os.path.exists('/home/yeukhon/pythonenv/sandbox/mysite')
True
>>> os.path.exists('/home/yeukhon/pythonenv/sandbox/mysite/settings.py')
True
>>> from django.core.management import setup_environ
>>> import mysite.settings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysite.settings
>>> setup_environ(mysite.settings)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'mysite' is not defined
>>> print sys.path
['',
/home/yeukhon/pythonenv/sandbox/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg',
'/home/yeukhon/pythonenv/sandbox/lib/python27.zip',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7/plat-linux2',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7/lib-tk',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7/lib-old',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/home/yeukhon/pythonenv/sandbox/lib/python2.7/site-packages'
¿Qué necesito hacer para corregir este problema? Gracias por tu tiempo.
EDITAR
Gracias por la respuesta.
He intentado lo siguiente:
(sandbox)[[email protected] mysite]# export PYTHONPATH="/home/yeukhon/pythonenv/sandbox/"
(sandbox)[[email protected] mysite]# export PYTHONPATH="/home/yeukhon/pythonenv/"
(sandbox)[[email protected] mysite]# deactivate
[[email protected] mysite]# source ../bin/activate
(sandbox)[[email protected] mysite]# django-admin.py runserver
Error: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings
>>> sys.path
['',.... '/home/yeukhon/pythonenv'.....]
Es ahora en el camino pitón. Pero todavía no puedo ejecutar el servidor.
centralizada Django Proyecto
Sí. Esa es una buena sugerencia. Entonces, supongo que todo lo que tengo que hacer es "crear un directorio llamado mydjango, luego crear proyectos dentro de mydjango". ¿Pero qué comandos necesitan ser cambiados/agregados? Estoy dispuesto a aprender buenas prácticas.
Muchas gracias.
Solución (Añadir a la variable de entorno)
PYTHONPATH=$PYTHONPATH:path-to-your-directory
# PYTHONPATH=$PYTHONPATH:/home/yeukhon/pythonenv/sandbox/
Pratt. Muchas gracias por tu tiempo. Acabo de agregar la ruta a sys.path. Ver mi edición Tal vez hice el agregar incorrectamente? Sin suerte. Gracias de cualquier forma. – CppLearner
No puede simplemente agregarlo a 'sys.path'. Eso fue creado un tiempo de ejecución. Debe estar en su variable de entorno 'PYTHONPATH'. –
Tienes razón. Tuve que PYTHONPATH = $ PYTHONPATH:/home/yeukhon/pythonenv/sandbox /. Gracias. – CppLearner