I'm deploying a NodeJS app through Heroku and utilizing child processes to run some python scripts. I was facing a few syntax errors when the app was first deployed, and after a bit of digging, I found out the python version was 2.7.17 when I needed 3.8 or higher, which made me ask:
How do I specify (or upgrade) the python version for a NodeJS app hosted on Heroku?
After a little looking around I stumbled upon this, which obviously didn't work (else I wouldn't be here asking). I followed the steps and added a runtime.txt file containing "python-3.8.6" (one of the supported python versions by Heroku) but upon checking the python version, 2.7.17 appeared again. I'm assuming the solution linked above focuses on Django/python based servers and doesn't work on NodeJS deployments. Otherwise, I am likely forgetting/missing an important step, which I can't really see anywhere.
Any help is appriciated.
Related
So, I am deploying my first django app to heroku for the first time. I have configured the app locally, pushed it to my remote repository. But when I push the code to my heroku repository, the build fails giving the reason that python 3.6.5 is not available on current stack (heroku-18). It also says here that heroku-18 supports 3.6.6. My simple question is "How do I deploy my python 3.6.5 app on current stack (heroku-18)?"
If you have a runtime.txt file, try changing it to python-3.6.6. 3.6.6 is a maintenance release, so code written for 3.6.5 should run on it fine.
Just try put it in your runtime.txt
python-3.6.4
It's working to me.
I have been trying to setup Django to work on IIS 7 Enterprise (Version 6.1 on Windows 7), but so far have been unable to. I am using Django 1.8.3 and Python 2.7. I am using PyISAPI to run Django on IIS. I have tried both the 2.6 version of PyISAPI and the 2.7 version (http://blog.wolfplusplus.com/?attachment_id=276). I have followed the following tutorials:
IIS Not Linking to Django with PyISAPIe
http://blog.wolfplusplus.com/?p=272
I have followed others also, and all of them do slightly different things. None of them have worked with me so far, and all of the tutorials seems to be a couple of years old. Can someone provide a straightforward up to date guide on how to setup Django 1.8 (running with Python 2.7) with IIS. There seems to be multiple approaches such as using FastCGI, but I have read that PyISAPI is much faster than FastCGI. My goal is to run a Django application on IIS.
I've just followed that guide with following corrections:
You should give permission on the site folder to App Pool's identity. I just went to App Pool's Advanced Settings > Process model > Identity and set it to local admin account for testing purposes.
Correct environment variable name in step 4.13 is DJANGO_SETTINGS_MODULE, underscores were eaten by markup
and everything worked fine! If it's not applicable in your case please provide some additional details.
I have my development environment setup on Win 7 like this:
Django development structure
Apache -server- C:\Program Files (x86)\Apache Software Foundation\Apache2.4
PostgreSQL -database- C:\Program Files\PostgreSQL\9.2
Django -framework- C:\Python27\Lib\site-packages\django
Python -code- C:\Python27
Project -root- C:\mysite
|----------apps
|----------HTML
|----------CSS
|----------JavaScript
|----------assets
I am attempting to keep this extremely simple to start out. There are 5 main directories each with a distinct purpose. All the code resides in the project folder.
compared to WAMP structure:
C:\WAMP
|----------C:\Apache
|----------C:\MySQL
|----------C:\PHP
|----------C:\www
I like how Apache, MySQL, and PHP all reside in a neat directory. I know to keep the root project OUTSIDE in another directory in Django for security reasons.
Is it fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?
Did I miss a core Django component and/or directory?
Will deploying and scaling be a problem?
I want this to be a guideline for beginning Django web programmers.
I can answer the question one by one:
Is if fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?
All over the place sounds weird but yes it is totally fine.
Did I miss a core Django component and/or directory?
No you don't miss anything, Django core is in site-packages folder already and your site code is mysite, which can be located anywhere you want.
Will deploying and scaling be a problem?
No it won't be a problem with current structure. You will deploy your mysite only, the other will be installed separately.
Something you should get familiar with when starting with Django development:
Most likely when you deploy your project, it will be on a Linux server, so install and learn Linux maybe?
virtualenv: Soon you will have to install Django, then a bunch of external packages to support your project. virtualenv helps you isolate your working environment. Well it's "unofficial" a must when you start with python development.
virtualenvwrapper to make your life easier when working with virtualenv
git and github or bitbucket: if you don't know git yet, you should now.
Apache is just web server, it is used to serve files, but to make a website you do not necessary need it. Django comes with its own development server. See :
python manage.py runserver
Apache is required when you are developing PHP websites because your computer do not know how to compile and interpret it. But for Django, you use the Python language, and you have already install it if you are using Django.
Read https://docs.djangoproject.com/en/1.5/intro/tutorial01/
And where it will be the time to set up your own server using Apache look at :
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/.
Scaling will be a problem on windows. Python in Apache on windows gets 64 threads in one process. Couple this with the GIL and you will have scaling issues.
Python and Apache on Linux don't have this same problem. Under Linux wsgi can create multiple processes that have multiple threads each, minimizing GIL issues.
WSGI in Apache on windows is not a scalable solution in my opinion.
However you can develop there and move to linux for deployment, I do it all the time.
You will want to take advantage of the Apache Alias directive to serve all your static content like css, js, favicon.ico. This frees up python to only handle requests that require logic.
the more I read the worse it gets... I am starting out with Python and I cannot make my
mind up on how to set up my dev environment. I want to use Python and Django to build web applications.
Ideally, I'd love to use and IDE on Win7 (which would help with tooltips and help about methods, classes, etc) and have the web app run on a virtual linux machine (need apache+mysql). I have downloaded the turnkey linux appliance for Django and it seems to work fine.
So, in the end, it is unclear to me if people here are recommending to edit my code on the same machine where the app runs. I'd prefer to code on the Win7 machine and then publish the app/files on the fly to the linux virtual box, then accessing the app via the browser.
This is the setup for my current php project at work and I think it works perfectly.
Please clarify if people normally code and run their web apps all on one machine only or not.
Thank you!
I don't know how it can be unclear to you "if people here are recommending to edit my code on the same machine where the app runs". The easy answer is no, no way, never, ever. There can be no ambiguity about that.
Edit Ah, apologies for the misunderstanding - you clarify in the comments that you're not talking about your production environment. In that case, yes it is a perfectly good idea - even preferable - to edit on the same machine as your development app is running. There's no reason not to, and it makes life a whole lot easier.
Note you shouldn't really use Apache in development: it requires a lot of configuration, and doesn't automatically reload after code changes without even more configuration. Use the development server. And in case you were concerned, all of this runs perfectly well on a Windows machine.
I agree with the comment. Personally, I use Aptana Studio (http://www.aptana.com/) alongside GIT to have local version control (integrates well into Aptana). From there on, it is easy to either deploy locally or push the changes to a remote GIT repo.
Since Python 2.6 is backward compatible to 2.52 , did anyone succeeded in using it with Google app Engine ( which supports 2.52 officially ).
I know i should try it myself. But i am a python and web-apps new bee and for me installation and configuration is the hardest part while getting started with something new in this domain.
( .... I am trying it myself in the meanwhile ....)
Thanks
I suppose logging module crashes if you try to start the dev environment. See the issue and a workaround.
After doing that change my code worked in 2.6 without any problems. I suggest using 2.5.x though so there are no other incompatibilities introduced in your code which would make your app fail on the live server.
There are a few issues with using Python 2.6 with the SDK, mostly related to the SDK's sandboxing, which is designed to imitate the sandbox limitations in production. Note, of course, that even if you get Python 2.6 running with the SDK, your code will still have to run under 2.5 in production.