Could not find a version that satisfies the requirement...Heroku deployment


#1

I get this error in my command line when attempting to deply to heroku

Could not find a version that satisfies the requirement hellowebapp-deploy (from versions: )

Any ideas?


#2

What does your requirements file have? Sounds like there is hellowebapp-deploy==1.0 (or something), where a version is specified but doesn’t exist in pypi. Either remove the version (making the line in requirements.py just hellowebapp-deploy or change it to hellowebapp-deploy==1.0.2


#3

Thanks a lot that worked just fine.

However further on in the process I am getting this error when running this command

heroku run python manage.py migrate

error:

ImportError: Could not import settings 'hellowebapp.settings_production' (Is it on sys.path? Is there an import error in the settings file?): No module named dj_database_url

I have been stuck on this for a while. Not too sure what to do or where to look to try and fix it.
Thanks for your help so far :)


#4

Did hellowebapp-deploy successfully install dj-database-url on Heroku? You’ve created a settings_production.py file and ran “heroku config:set DJANGO_SETTINGS_MODULE=hellowebapp.settings_production” right?


#5

Yes it did deploy. And yeah I have created the settings_production file and ran all the commands all correctly


#6

What does your wsgi file look like?


#7
"""
WSGI config for hellowebapp project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
    "hellowebapp.settings_production")

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

application = get_wsgi_application()
application = DjangoWhiteNoise(application)

#8

managed to get it past that point if I remove psycog2 from the requirements. However I get this page when I try to open the app.


#9

Yeah psycopg2 is required by heroku. What happens when you run heroku run pip freeze? Checking what was installed on the Heroku server.


#10

I rolled back a to an earlier chunk of code. It seemed to like that. Unsure what fixed the problem.

However my deployed site has no css, just html?


#11

Look at the HTML source, what do the paths to the CSS show?


#12
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}" />
<link rel="stylesheet" href="{% static 'css/style.css' %}" />

#13

Sorry, not that — I mean the source in your browser. If you’re in Chrome on Mac, go to View --> Developer --> View Source. Find what the link is in Heroku, it should give you a clue about why it’s not being shown.


#14

I have had it randomly load some css but not others (after I added whitenoise to installed apps)
However it stopped working after I pushed to heroku again. I havent been able to replicate it since.

Here is what I am getting


#15

I learned through deploying on heroku that Django does not serve static files when DEBUG is set to False. This is where whitenoise comes into play and will setup all the things you need for you.

Look through each setting on this page and verify that you have it setup on your end:

For instance, I was missing this line in settings.py:

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

And it completely messed up heroku deployment of static files.

You can also run the following command to see if heroku is able to serve static files:

heroku run python manage.py collectstatic --noinput 

If you are getting an error there it is likely a configuration issue with the whitenoise package.


#16

I’ve tried the above steps. This is what I get now in my browser

It seems there is something going really wrong here. I rebuilt the code from scratch and I am still getting the exact same problem as above.

requirements.txt

dj-database-url==0.3.0
Django==1.7.8
django-contrib-comments==1.6.1
django-haystack==2.4.0
django-registration-redux==1.1
hellowebapp-deploy==1.0.2
Pillow==2.9.0
waitress==0.8.9
whitenoise==2.0.2
psycopg2==2.6

wsgi.py

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellowebapp.settings_production")

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

application = get_wsgi_application()
application = DjangoWhiteNoise(application)

settings_production.py

# Inherit from standard settings file for default
from hellowebapp.settings import *

# Everything below will override our standard settings:

# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']

# Set debug to False
DEBUG = False

# Static asset configuration
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

settings.py (static part)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

settings.py (installed apps)

INSTALLED_APPS = (
    'collection',
    'haystack',
    'django.contrib.admin',
    'django.contrib.sites',
    'django_comments',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'registration',
)

#17

There should be logging in Heroku, what is the error there? http://stackoverflow.com/questions/2671454/heroku-how-to-see-all-the-logs


Internal Server Error - generated by waitress
#18

I tried a few different things and it seems having my settings.py file exactly like this is the only way that static files will be served. The problem has been resolved.

   STATIC_ROOT = 'staticfiles'
    STATIC_URL = '/static/'
    
    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, 'static'),
    )
    STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

#19

Dear Limedaring, I have the same issues while deploying my Flask file into Heroku. Even after removing and mentioning the right current version, I have the following error.

 Could not find a version that satisfies the requirement cdecimal==2.3.0

Kindly advise. I am spending hours in it. Thanks.


#20

Hi @amarimuthu, unfortunately if you are deploying a Flask project (not the Django one from Hello Web App), don’t think I can help you! Sounds maybe that version of cdecimal doesn’t exist? Try posting on Stack Overflow, maybe they can help you there. :)