Python ModuleNotFoundError:没有名为';django';在希罗库
我尝试在Heroku中部署我的应用程序,出现以下错误:Python ModuleNotFoundError:没有名为';django';在希罗库,python,heroku,Python,Heroku,我尝试在Heroku中部署我的应用程序,出现以下错误: 2018-05-03T14:35:40.682441+00:00 heroku[web.1]: Starting process with command `python manage.py runserver` 2018-05-03T14:35:41.960741+00:00 app[web.1]: Traceback (most recent call last): 2018-05-03T14:35:41.960765+00:00 a
2018-05-03T14:35:40.682441+00:00 heroku[web.1]: Starting process with command `python manage.py runserver`
2018-05-03T14:35:41.960741+00:00 app[web.1]: Traceback (most recent call last):
2018-05-03T14:35:41.960765+00:00 app[web.1]: File "manage.py", line 8, in <module>
2018-05-03T14:35:41.960858+00:00 app[web.1]: from django.core.management import execute_from_command_line
2018-05-03T14:35:41.960872+00:00 app[web.1]: ModuleNotFoundError: No module named 'django'
2018-05-03T14:35:41.960873+00:00 app[web.1]:
2018-05-03T14:35:41.960875+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2018-05-03T14:35:41.960876+00:00 app[web.1]:
2018-05-03T14:35:41.960879+00:00 app[web.1]: Traceback (most recent call last):
2018-05-03T14:35:41.960895+00:00 app[web.1]: File "manage.py", line 14, in <module>
2018-05-03T14:35:41.961003+00:00 app[web.1]: ) from exc
2018-05-03T14:35:41.961016+00:00 app[web.1]: 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?
2018-05-03T14:35:42.013265+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-03T14:35:42.008966+00:00 heroku[web.1]: Process exited with status 1
我的runtime.txt
python-3.6.5
我的程序文件(“myapphere”中是我的应用程序名)
问题是我让“git push heroku master”出现错误,我不知道会发生什么
部署日志:
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (13/13), 1.11 KiB | 0 bytes/s, done.
Total 13 (delta 7), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote: Installing dependencies from Pipfile…
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 53.5M
remote: -----> Launching...
remote: Released v21
remote: https://sbceval.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/sbceval.git
df538a8..a82ea89 master -> master
根据您的日志,您有
Pipfile
和requirements.txt
。删除其中一个,您应该会没事的我必须运行“pipenv锁”命令,然后在Heroku接受之前删除pipenv文件。当这些事情发生时,他们是如此挑剔,如此无益 您确定不需要在requirementes文件中列出django吗?但是,在requirements中:django heroku==0.3.1我已经检查了部署到heroku的我的项目-他们的Procfile
文件只包含gunicorn
行,没有python manage.py runserver
。不过,我不确定这是否是问题所在。我也没有使用django heroku,这就是为什么我问了requirementsI删除命令“python manage.py runserver”,但是错误出现了:bash:gunicorn:command not found你说你有requirements.txt,但是heroky说关于pipfile它回答了这个问题,我不得不运行“pipenv lock”命令。我还删除了带有“heroku pg:reset”的heroku数据库,如果这增加了更多信息的话。删除了pipfile和pipfile.lock,它成功了。
web: gunicorn myapphere.wsgi
web: python manage.py runserver
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (13/13), 1.11 KiB | 0 bytes/s, done.
Total 13 (delta 7), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote: Installing dependencies from Pipfile…
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 53.5M
remote: -----> Launching...
remote: Released v21
remote: https://sbceval.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/sbceval.git
df538a8..a82ea89 master -> master