Reputation: 185
I am setting up a backend for my website with Heroku and Python. By doing so I am following Heroku's setup. But my problem arose at this step here.
when I try to run: python3 manage.py collectstatic
I get the following below:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
collected = self.collect()
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 125, in list
for path in utils.get_files(storage, ignore_patterns):
File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
directories, files = storage.listdir(location)
File "/usr/local/lib/python3.7/site-packages/django/core/files/storage.py", line 313, in listdir
for entry in os.listdir(path):
FileNotFoundError: [Errno 2] No such file or directory: '/Users/aaronmiller/Development/python-getting-started/static'
I have tried the following the instructions step by step and always get stuck at the part above. With:
MacOS 10.14
Python 2.7.15
Python 3.7.2
psql(PostgreSQL) 11.0
pip3 list
Package Version
--------------- -------
dj-database-url 0.5.0
Django 2.1.4
django-heroku 0.3.1
gunicorn 19.9.0
pip 18.1
psycopg2 2.7.6.1
pytz 2018.7
setuptools 40.6.3
wheel 0.32.3
whitenoise 4.1.2
heroku pg:info
=== DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 10.6
Created: 2018-12-31 18:40 UTC
Data Size: 7.6 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Let me know if there is any other info I can provide and I will.
Update
I stopped trying this with python 2 and then I took out the code below that I added to settings.py
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
Upvotes: 0
Views: 100
Reputation: 3682
The django-heroku
package requires Python 3, see the README file: https://github.com/heroku/django-heroku/blob/master/README.rst
edit: It seems you have python3 available on your system, so try just running the following:
python3 manage.py collectstatic
You'll need to re-install any dependencies you installed for python2 (presumably, using pip
) for the python3 environment. Do you have pip3
available?
Upvotes: 1