How to fix Heroku application error with 'File not found'?

血红的双手。 提交于 2021-02-11 17:01:08

问题


I'm trying to run heroku and can't seem to get the application to run.

The error log states:

Last login: Sun Jan 12 09:37:02 on ttys001
(base) adam:dash adam$ heroku logs --tail
 ›   Warning: heroku update available from 7.35.0 to 7.35.1.
2020-01-12T14:36:05.716972+00:00 app[web.1]: [2020-01-12 14:36:05 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-01-12T14:36:06.163957+00:00 app[web.1]: [2020-01-12 14:36:06 +0000] [4] [INFO] Shutting down: Master
2020-01-12T14:36:06.164141+00:00 app[web.1]: [2020-01-12 14:36:06 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-01-12T14:36:06.316849+00:00 heroku[web.1]: State changed from up to crashed
2020-01-12T14:36:06.321823+00:00 heroku[web.1]: State changed from crashed to starting
2020-01-12T14:36:06.294266+00:00 heroku[web.1]: Process exited with status 3
2020-01-12T14:36:07.000000+00:00 app[api]: Build succeeded
2020-01-12T14:36:13.134727+00:00 heroku[web.1]: Starting process with command `gunicorn app:server`
2020-01-12T14:36:15.150029+00:00 app[web.1]: [2020-01-12 14:36:15 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-01-12T14:36:15.150722+00:00 app[web.1]: [2020-01-12 14:36:15 +0000] [4] [INFO] Listening at: http://0.0.0.0:18933 (4)
2020-01-12T14:36:15.150846+00:00 app[web.1]: [2020-01-12 14:36:15 +0000] [4] [INFO] Using worker: sync
2020-01-12T14:36:15.155588+00:00 app[web.1]: [2020-01-12 14:36:15 +0000] [10] [INFO] Booting worker with pid: 10
2020-01-12T14:36:15.246525+00:00 app[web.1]: [2020-01-12 14:36:15 +0000] [11] [INFO] Booting worker with pid: 11
2020-01-12T14:36:15.848064+00:00 heroku[web.1]: State changed from starting to up
2020-01-12T14:36:16.580950+00:00 app[web.1]: [2020-01-12 14:36:16 +0000] [10] [ERROR] Exception in worker process
2020-01-12T14:36:16.580989+00:00 app[web.1]: Traceback (most recent call last):
2020-01-12T14:36:16.580992+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-01-12T14:36:16.580995+00:00 app[web.1]: worker.init_process()
2020-01-12T14:36:16.580997+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-01-12T14:36:16.581000+00:00 app[web.1]: self.load_wsgi()
2020-01-12T14:36:16.581001+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-01-12T14:36:16.581003+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-01-12T14:36:16.581005+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-01-12T14:36:16.581007+00:00 app[web.1]: self.callable = self.load()
2020-01-12T14:36:16.581009+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-01-12T14:36:16.581011+00:00 app[web.1]: return self.load_wsgiapp()
2020-01-12T14:36:16.581013+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-01-12T14:36:16.581015+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-01-12T14:36:16.581017+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2020-01-12T14:36:16.581019+00:00 app[web.1]: mod = importlib.import_module(module)
2020-01-12T14:36:16.581023+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2020-01-12T14:36:16.581025+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-01-12T14:36:16.581027+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2020-01-12T14:36:16.581028+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2020-01-12T14:36:16.581030+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2020-01-12T14:36:16.581031+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2020-01-12T14:36:16.581032+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2020-01-12T14:36:16.581034+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-01-12T14:36:16.581035+00:00 app[web.1]: File "/app/app.py", line 8, in <module>
2020-01-12T14:36:16.581037+00:00 app[web.1]: df = pd.read_csv("/Users/adam31/Desktop/abc.csv")
2020-01-12T14:36:16.581038+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 685, in parser_f
2020-01-12T14:36:16.581040+00:00 app[web.1]: return _read(filepath_or_buffer, kwds)
2020-01-12T14:36:16.581041+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 457, in _read
2020-01-12T14:36:16.581043+00:00 app[web.1]: parser = TextFileReader(fp_or_buf, **kwds)
2020-01-12T14:36:16.581044+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 895, in __init__
2020-01-12T14:36:16.581046+00:00 app[web.1]: self._make_engine(self.engine)
2020-01-12T14:36:16.581047+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 1135, in _make_engine
2020-01-12T14:36:16.581049+00:00 app[web.1]: self._engine = CParserWrapper(self.f, **self.options)
2020-01-12T14:36:16.581050+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 1917, in __init__
2020-01-12T14:36:16.581052+00:00 app[web.1]: self._reader = parsers.TextReader(src, **kwds)
2020-01-12T14:36:16.581053+00:00 app[web.1]: File "pandas/_libs/parsers.pyx", line 382, in pandas._libs.parsers.TextReader.__cinit__
2020-01-12T14:36:16.581055+00:00 app[web.1]: File "pandas/_libs/parsers.pyx", line 689, in pandas._libs.parsers.TextReader._setup_parser_source
2020-01-12T14:36:16.581063+00:00 app[web.1]: FileNotFoundError: [Errno 2] File b'/Users/adam31/Desktop/abc.csv' does not exist: b'/Users/adam31/Desktop/abc.csv'
2020-01-12T14:36:16.581454+00:00 app[web.1]: [2020-01-12 14:36:16 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-01-12T14:36:16.670227+00:00 app[web.1]: [2020-01-12 14:36:16 +0000] [11] [ERROR] Exception in worker process
2020-01-12T14:36:16.670231+00:00 app[web.1]: Traceback (most recent call last):
2020-01-12T14:36:16.670236+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-01-12T14:36:16.670238+00:00 app[web.1]: worker.init_process()
2020-01-12T14:36:16.670240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-01-12T14:36:16.670242+00:00 app[web.1]: self.load_wsgi()
2020-01-12T14:36:16.670244+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-01-12T14:36:16.670246+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-01-12T14:36:16.670248+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-01-12T14:36:16.670250+00:00 app[web.1]: self.callable = self.load()
2020-01-12T14:36:16.670252+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-01-12T14:36:16.670254+00:00 app[web.1]: return self.load_wsgiapp()
2020-01-12T14:36:16.670256+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-01-12T14:36:16.670258+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-01-12T14:36:16.670260+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2020-01-12T14:36:16.670262+00:00 app[web.1]: mod = importlib.import_module(module)
2020-01-12T14:36:16.670264+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2020-01-12T14:36:16.670266+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-01-12T14:36:16.670269+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2020-01-12T14:36:16.670271+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2020-01-12T14:36:16.670273+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2020-01-12T14:36:16.670275+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2020-01-12T14:36:16.670277+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2020-01-12T14:36:16.670279+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-01-12T14:36:16.670281+00:00 app[web.1]: File "/app/app.py", line 8, in <module>
2020-01-12T14:36:16.670283+00:00 app[web.1]: df = pd.read_csv("/Users/adam31/Desktop/abc.csv")
2020-01-12T14:36:16.670285+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 685, in parser_f
2020-01-12T14:36:16.670288+00:00 app[web.1]: return _read(filepath_or_buffer, kwds)
2020-01-12T14:36:16.670290+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 457, in _read
2020-01-12T14:36:16.670292+00:00 app[web.1]: parser = TextFileReader(fp_or_buf, **kwds)
2020-01-12T14:36:16.670294+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 895, in __init__
2020-01-12T14:36:16.670296+00:00 app[web.1]: self._make_engine(self.engine)
2020-01-12T14:36:16.670298+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 1135, in _make_engine
2020-01-12T14:36:16.670300+00:00 app[web.1]: self._engine = CParserWrapper(self.f, **self.options)
2020-01-12T14:36:16.670302+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 1917, in __init__
2020-01-12T14:36:16.670304+00:00 app[web.1]: self._reader = parsers.TextReader(src, **kwds)
2020-01-12T14:36:16.670306+00:00 app[web.1]: File "pandas/_libs/parsers.pyx", line 382, in pandas._libs.parsers.TextReader.__cinit__
2020-01-12T14:36:16.670308+00:00 app[web.1]: File "pandas/_libs/parsers.pyx", line 689, in pandas._libs.parsers.TextReader._setup_parser_source
2020-01-12T14:36:16.670339+00:00 app[web.1]: FileNotFoundError: [Errno 2] File b'/Users/adam31/Desktop/abc.csv' does not exist: b'/Users/adam31/Desktop/abc.csv'
2020-01-12T14:36:16.670752+00:00 app[web.1]: [2020-01-12 14:36:16 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-01-12T14:36:16.796730+00:00 app[web.1]: [2020-01-12 14:36:16 +0000] [4] [INFO] Shutting down: Master
2020-01-12T14:36:16.796849+00:00 app[web.1]: [2020-01-12 14:36:16 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-01-12T14:36:16.888718+00:00 heroku[web.1]: State changed from up to crashed
2020-01-12T14:36:16.868326+00:00 heroku[web.1]: Process exited with status 3
2020-01-12T14:36:22.387391+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nba-proj-knox.herokuapp.com request_id=9cda17d1-4bf8-499b-b1d4-61eab9e07ab1 fwd="69.127.72.249" dyno=web.1 connect=5000ms service= status=503 bytes= protocol=https
2020-01-12T14:36:23.365140+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nba-proj-knox.herokuapp.com request_id=6a9dd876-eb1b-4052-824f-274afc5f183b fwd="69.127.72.249" dyno= connect= service= status=503 bytes= protocol=https

I can see that it can't find the file from my app that lives on my desktop - 'abc.csv' - but I can assure you it is there and that the filename is typed correctly. After all - the app runs perfectly when I run it locally. It's when I try to deploy it when the issue comes up.


回答1:


When you deploy your application to Heroku it will be hosted on a server somewhere that doesn't have access to your local machine, nor the files on your local machine. The application will run fine locally as it is able to see the abc.csv file.

To fix the error, you will need to upload the abc.csv file to Heroku. If you have used git, then you can do this by uploading the csv file to your repository and using a relative path.



来源:https://stackoverflow.com/questions/59704991/how-to-fix-heroku-application-error-with-file-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!