2017-09-01 79 views
0

我想在服務器上部署我的Python Django項目(使用Nginx)。 但是,當我收集靜Django部署collectstatic錯誤

python manage.py collectstatics 

我得到了一個錯誤:

Couldn't import Django. Are you sure it's installed and " ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

但我有Django和 「接通」 的virtualenv

PIP凍結:

certifi==2017.4.17 
chardet==3.0.4 
command-not-found==0.3 
Django==1.10.7 
django-appconf==1.0.2 
django-ckeditor==5.3.0 
django-haystack==2.6.1 
django-imagekit==4.0.1 
django-js-asset==0.1.1 
django-material==1.0.0 
django-parler==1.8 
flickrapi==2.3 
gunicorn==19.7.1 
idna==2.5 
language-selector==0.1 
oauthlib==2.0.2 
olefile==0.44 
pilkit==2.0 
Pillow==4.2.1 
pycurl==7.43.0 
pygobject==3.20.0 
python-apt==1.1.0b1 
python-debian==0.1.27 
python-systemd==231 
pytz==2017.2 
requests==2.18.1 
requests-oauthlib==0.8.0 
requests-toolbelt==0.8.0 
requirements==0.1 
six==1.10.0 
solid-i18n==1.4.1 
ssh-import-id==5.5 
ufw==0.35 
unattended-upgrades==0.1 
urllib3==1.21.1 
virtualenv==15.0.1 
Whoosh==2.7.4 
+0

之後,您就'workon'顯示你'PIP freeze',請 –

+0

你有Django的安裝的virtualenv之外? – phd

+0

@BearBrown,我將它添加到我的問題 – SerjR

回答

0

請檢查你在nginx配置文件中的路徑。

location /static/ { 
     alias <static directory path>; 
    } 

它應該是相同setting.py SETTING_ROOT路徑

STATIC_ROOT = '<static directory path>' 
+0

我嘗試第一次配置Nginx。你的意思是nginx.conf文件?其中我沒有這樣的路徑,因爲沒有「location {}」 – SerjR

+0

是的,nginx.conf文件。 服務器{ ... 位置/靜態自動索引打開; } } – Dharmesh