9👍
I had this problem too.
I wanted to deploy a django app which use numpy, sckit-learn and some other conda packages.
I used the conda-buildpack but the installed packages weren’t accessible from inside django. So I created a fork which extended the PYTHONPATH
and removed the part where dependencies installed withpip install -r requirements.txt
because this part clashed with memcached on heroku.
Now I have a multiple buildpack setup
with the default heroku python buildpack and my custom condas buildpack fork
The requirements.txt
is processed by the python buildpack and the conda-requirements.txt
by the conda buildpack. Works like a charm for me.
2👍
If you are in conda environment then using these steps might help to deploy your Django app to Heroku:
Before deploying, make the following four changes to your project so it’s ready to deploy online with Heroku:
- Install
gunicorn
as your web-server.
( Since, you are using conda environment gunicorn is not currently available at any conda channels to install. So, usepip install gunicorn
) - Add
requirements.txt
file to your project’s base directory and inside it add the modules names along with it versions or simply copy the contents that you get after you runpip freeze
command. -
Make a new file:
Procfile
& inside it add the following:web: gunicorn [Project_name].wsgi –log-file –
(Here
[Project_name]
is your own project’s directory name)This says to use your existing [Project_name].wsgi file but with gunicorn.
-
Make just a single change to
settings.py
file:ALLOWED_HOSTS = [‘*’]
( The wildcard Asterisk * means all domains are acceptable to keep things simple. )
Now finally you can deploy using these steps:
-
Create a new app on Heroku:
On CLI typeheroku create
(Heroku will create a random name for your app; [your_app_name])
-
Add a git remote “hook” for Heroku:
heroku git:remote -a [your_app_name]
-
Ignore static files:
heroku config:set DISABLE_COLLECTSTATIC=1
-
Push our code to Heroku:
git push heroku master
-
Finally, make your Heroku app live:
heroku ps:scale web=1
( Here, web=1
for basic Heroku services )
To open your app: heroku open
Your app should now be live on Heroku.
- [Django]-Failing to install psycopg2-binary on new docker container
- [Django]-Where to store secret keys DJANGO
- [Django]-How to monkey patch Django?
1👍
I was able to deploy using Firebolt’s method, with the following modifications:
On step 2: when adding the requirements.txt file to the project base directory, if you are copying the contents of the pip freeze command, you will have to replace any references to file paths with the version of the package.
example: replace "asgiref @ file:///tmp/build/80754af9/asgiref_1602513567813/work" with "asgiref==3.3.0".
In order to check which version of the package to install:
- run the command "conda env export > environment.yml",
- open up environment.yml, and
- check the list for the version that corresponds to the package in question
- [Django]-Django REST Framework: adding additional field to ModelSerializer
- [Django]-Get protocol + host name from URL
- [Django]-How to show related items using DeleteView in Django?