我正在尝试修改我的虚拟环境以添加一个新库(django-cron)。当我执行点子列表时
(env_dili_py27)[todd@somewhere site-packages]$ pip list
Django (1.5.4)
django-common-helpers (0.6.0)
django-cron (0.3.3)
django-filter (0.7)
djangorestframework (2.3.8)
Markdown (2.3.1)
MySQL-python (1.2.4)
pip (1.4.1)
setuptools (0.9.8)
South (0.8.4)
wsgiref (0.1.2)
但是软件包列表不包括 djanago cron:
(env_dili_py27)[todd@somewhere python2.7]$ ls site-packages/ -l
total 448
drwxrwxr-x 17 todd todd 4096 Oct 19 08:54 django
drwxrwxr-x 2 todd todd 4096 Oct 19 08:54 Django-1.5.4-py2.7.egg-info
drwxrwxr-x 2 todd todd 4096 Oct 19 08:56 django_filter-0.7-py2.7.egg-info
drwxrwxr-x 3 todd todd 4096 Oct 19 08:56 django_filters
drwxr-xr-x 2 root root 4096 Oct 22 11:02 djangorestframework-2.3.8-py2.7.egg-info
-rw-rw-r-- 1 todd todd 126 Jul 15 2013 easy_install.py
-rw-rw-r-- 1 todd todd 340 Oct 19 08:28 easy_install.pyc
drwxrwxr-x 3 todd todd 4096 Oct 19 08:54 markdown
drwxrwxr-x 2 todd todd 4096 Oct 19 08:54 Markdown-2.3.1-py2.7.egg-info
drwxrwxr-x 2 todd todd 4096 Oct 19 08:28 _markerlib
drwxr-xr-x 3 root root 4096 Oct 22 11:08 MySQLdb
-rw-r--r-- 1 root root 2352 Oct 22 11:07 _mysql_exceptions.py
-rw-r--r-- 1 root root 4555 Oct 22 11:08 _mysql_exceptions.pyc
drwxr-xr-x 2 root root 4096 Oct 22 11:08 MySQL_python-1.2.4-py2.7.egg-info
-rwxr-xr-x 1 root root 139849 Oct 22 11:08 _mysql.so
drwxrwxr-x 6 todd todd 4096 Oct 19 08:28 pip
drwxrwxr-x 2 todd todd 4096 Oct 19 08:50 pip-1.4.1-py2.7.egg-info
-rw-rw-r-- 1 todd todd 101108 Jul 15 2013 pkg_resources.py
-rw-rw-r-- 1 todd todd 114723 Oct 19 08:28 pkg_resources.pyc
drwxr-xr-x 9 root root 4096 Oct 22 11:02 rest_framework
drwxrwxr-x 5 todd todd 4096 Oct 19 08:28 setuptools
drwxrwxr-x 2 todd todd 4096 Oct 19 08:50 setuptools-0.9.8-py2.7.egg-info
在我的 settings.py 中,我引用了 django_cron 库(参考:https ://github.com/Tivix/django-cron ):
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cron',
'rest_framework',
'somewhereApp',
)
这是我收到的异常日志:
[Tue Feb 04 15:05:05 2014] [info] [client 76.119.143.226] mod_wsgi (pid=10049, process='api.somewhere.com', application='api.somewhere.com|'): Loading WSGI script '/var/www/python.somewhere.com/somewhere/wsgi.py'.
[Tue Feb 04 15:05:06 2014] [error] Internal Server Error: /
[Tue Feb 04 15:05:06 2014] [error] Traceback (most recent call last):
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/core/handlers/base.py", line 92, in get_response
[Tue Feb 04 15:05:06 2014] [error] response = middleware_method(request)
[Tue Feb 04 15:05:06 2014] [error] File "/var/www/python.somewhere.com/somewhereApp/authentication.py", line 62, in process_request
[Tue Feb 04 15:05:06 2014] [error] user = lookupUserById(userId)
[Tue Feb 04 15:05:06 2014] [error] File "/var/www/python.somewhere.com/somewhereApp/authentication.py", line 15, in lookupUserById
[Tue Feb 04 15:05:06 2014] [error] user = diliModels.User.objects.get(user_id=userId)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/manager.py", line 143, in get
[Tue Feb 04 15:05:06 2014] [error] return self.get_query_set().get(*args, **kwargs)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/query.py", line 395, in get
[Tue Feb 04 15:05:06 2014] [error] clone = self.filter(*args, **kwargs)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/query.py", line 669, in filter
[Tue Feb 04 15:05:06 2014] [error] return self._filter_or_exclude(False, *args, **kwargs)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/query.py", line 687, in _filter_or_exclude
[Tue Feb 04 15:05:06 2014] [error] clone.query.add_q(Q(*args, **kwargs))
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1271, in add_q
[Tue Feb 04 15:05:06 2014] [error] can_reuse=used_aliases, force_having=force_having)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1139, in add_filter
[Tue Feb 04 15:05:06 2014] [error] process_extras=process_extras)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1325, in setup_joins
[Tue Feb 04 15:05:06 2014] [error] field, model, direct, m2m = opts.get_field_by_name(name)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/options.py", line 351, in get_field_by_name
[Tue Feb 04 15:05:06 2014] [error] cache = self.init_name_map()
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/options.py", line 380, in init_name_map
[Tue Feb 04 15:05:06 2014] [error] for f, model in self.get_all_related_m2m_objects_with_model():
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/options.py", line 469, in get_all_related_m2m_objects_with_model
[Tue Feb 04 15:05:06 2014] [error] cache = self._fill_related_many_to_many_cache()
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/options.py", line 483, in _fill_related_many_to_many_cache
[Tue Feb 04 15:05:06 2014] [error] for klass in get_models(only_installed=False):
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/loading.py", line 197, in get_models
[Tue Feb 04 15:05:06 2014] [error] self._populate()
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
[Tue Feb 04 15:05:06 2014] [error] self.load_app(app_name, True)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/db/models/loading.py", line 94, in load_app
[Tue Feb 04 15:05:06 2014] [error] app_module = import_module(app_name)
[Tue Feb 04 15:05:06 2014] [error] File "/home/todd/Envs/env_dili_py27/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Tue Feb 04 15:05:06 2014] [error] __import__(name)
[Tue Feb 04 15:05:06 2014] [error] ImportError: No module named django_cron
我卸载了 django-cron 并详细地重新安装了它:
(env_dili_py27)[todd@somewhere site-packages]$ pip install django-cron -v
Downloading/unpacking django-cron
Using version 0.3.3 (newest of versions: 0.3.3, 0.3.2, 0.3.1, 0.3.0, 0.2.9, 0.2.8, 0.2.7, 0.2.6, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2, 0.1.2)
Downloading django-cron-0.3.3.tar.gz
Downloading from URL https://pypi.python.org/packages/source/d/django-cron/django-cron-0.3.3.tar.gz#md5=586bed6c699e6b7f78eac2e83c8f0d6e (from https://pypi.python.org/simple/django-cron/)
Running setup.py egg_info for package django-cron
running egg_info
creating pip-egg-info/django_cron.egg-info
writing requirements to pip-egg-info/django_cron.egg-info/requires.txt
writing pip-egg-info/django_cron.egg-info/PKG-INFO
writing top-level names to pip-egg-info/django_cron.egg-info/top_level.txt
writing dependency_links to pip-egg-info/django_cron.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/django_cron.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/django_cron.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/django_cron.egg-info/SOURCES.txt'
Requirement already satisfied (use --upgrade to upgrade): Django>=1.5.0 in /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages (from django-cron)
Requirement already satisfied (use --upgrade to upgrade): South>=0.8.1 in /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages (from django-cron)
Requirement already satisfied (use --upgrade to upgrade): django-common-helpers>=0.5.1 in /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages (from django-cron)
Installing collected packages: django-cron
Running setup.py install for django-cron
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/django_cron
copying django_cron/timezone.py -> build/lib/django_cron
copying django_cron/admin.py -> build/lib/django_cron
copying django_cron/__init__.py -> build/lib/django_cron
copying django_cron/test_settings.py -> build/lib/django_cron
copying django_cron/tests.py -> build/lib/django_cron
copying django_cron/cron.py -> build/lib/django_cron
copying django_cron/models.py -> build/lib/django_cron
creating build/lib/django_cron/migrations
copying django_cron/migrations/__init__.py -> build/lib/django_cron/migrations
copying django_cron/migrations/0001_initial.py -> build/lib/django_cron/migrations
copying django_cron/migrations/0002_auto__add_field_cronjoblog_ran_at_time.py -> build/lib/django_cron/migrations
copying django_cron/migrations/0003_auto__add_index_cronjoblog_end_time__add_index_cronjoblog_ran_at_time_.py -> build/lib/django_cron/migrations
creating build/lib/django_cron/management
copying django_cron/management/__init__.py -> build/lib/django_cron/management
creating build/lib/django_cron/management/commands
copying django_cron/management/commands/__init__.py -> build/lib/django_cron/management/commands
copying django_cron/management/commands/runcrons.py -> build/lib/django_cron/management/commands
running egg_info
writing requirements to django_cron.egg-info/requires.txt
writing django_cron.egg-info/PKG-INFO
writing top-level names to django_cron.egg-info/top_level.txt
writing dependency_links to django_cron.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'django_cron.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'django_cron.egg-info/SOURCES.txt'
running install_lib
creating /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
copying build/lib/django_cron/timezone.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
copying build/lib/django_cron/admin.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
copying build/lib/django_cron/__init__.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
copying build/lib/django_cron/test_settings.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
creating /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations
copying build/lib/django_cron/migrations/__init__.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations
copying build/lib/django_cron/migrations/0001_initial.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations
copying build/lib/django_cron/migrations/0002_auto__add_field_cronjoblog_ran_at_time.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations
copying build/lib/django_cron/migrations/0003_auto__add_index_cronjoblog_end_time__add_index_cronjoblog_ran_at_time_.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations
copying build/lib/django_cron/tests.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
copying build/lib/django_cron/cron.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
creating /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management
copying build/lib/django_cron/management/__init__.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management
creating /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management/commands
copying build/lib/django_cron/management/commands/__init__.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management/commands
copying build/lib/django_cron/management/commands/runcrons.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management/commands
copying build/lib/django_cron/models.py -> /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/timezone.py to timezone.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/admin.py to admin.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/__init__.py to __init__.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/test_settings.py to test_settings.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations/__init__.py to __init__.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations/0001_initial.py to 0001_initial.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations/0002_auto__add_field_cronjoblog_ran_at_time.py to 0002_auto__add_field_cronjoblog_ran_at_time.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/migrations/0003_auto__add_index_cronjoblog_end_time__add_index_cronjoblog_ran_at_time_.py to 0003_auto__add_index_cronjoblog_end_time__add_index_cronjoblog_ran_at_time_.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/tests.py to tests.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/cron.py to cron.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management/__init__.py to __init__.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management/commands/__init__.py to __init__.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/management/commands/runcrons.py to runcrons.pyc
byte-compiling /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron/models.py to models.pyc
running install_egg_info
Copying django_cron.egg-info to /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/django_cron-0.3.3-py2.7.egg-info
running install_scripts
writing list of installed files to '/tmp/pip-y2KoCb-record/install-record.txt'
Successfully installed django-cron
Cleaning up...
Removing temporary dir /home/todd/.virtualenvs/env_dili_py27/build...
(env_dili_py27)[todd@somewhere site-packages]$
ANLS
[todd@somewhere site-packages]$ ls /home/todd/.virtualenvs/env_dili_py27/lib/python2.7/site-packages/
django django_filter-0.7-py2.7.egg-info Markdown-2.3.1-py2.7.egg-info _mysql.so setuptools
Django-1.5.4-py2.7.egg-info django_filters _markerlib pip setuptools-0.9.8-py2.7.egg-info
django_common djangorestframework-2.3.8-py2.7.egg-info MySQLdb pip-1.4.1-py2.7.egg-info south
django_common_helpers-0.6.0-py2.7.egg-info easy_install.py _mysql_exceptions.py pkg_resources.py South-0.8.4-py2.7.egg-info
django_cron easy_install.pyc _mysql_exceptions.pyc pkg_resources.pyc
django_cron-0.3.3-py2.7.egg-info markdown MySQL_python-1.2.4-py2.7.egg-info rest_framework
[todd@somewhere site-packages]$
所以看起来它现在已经安装了。我做的唯一不同的事情是在...上安装详细命令
等等,我想我看到了什么。我正在使用从以下位置加载的 python 运行 django:
/home/todd/Envs/env_dili_py27/...
但图书馆安装在
/home/todd/.virtualenvs/env_dili_py27/...
目录路径中的.virtualenvs是什么(我是 django/python 和 linux 的新手)?