Hello, I'm a python beginner & I'm learning it on my own. So, I've few (dumb) questions about it.

  • Where should I host a python project on linux? I'm sure there'd be multiple choices. So, Where would you host it & on what circumstances?

  • I understand that virtualenv creates a virtual environment separate from others. But, why should one need it? Do we use it in production too, if so, why?

  • If I want to create a web application using python? What server should I choose & on what basis should I choose them for a given project.

Thank you very much in advance. :)

Where should I host a python project on linux? I'm sure there'd be multiple choices. So, Where would you host it & on what circumstances?

Github,Bitbucket...
If you mean web-host,pythonanywhere,Heroku,Webfaction,Digital ocean...

I understand that virtualenv creates a virtual environment separate from others. But, why should one need it? Do we use it in production too, if so, why?

You pip install stuff into virtualenv,
so you always get newest versions of modules/package.
It's isolatet,so it don't mess with your OS version of Python.
As you see in this Getting Started tutorial is normal to use virtualenv when using a web-host.

If I want to create a web application using python? What server should I choose & on what basis should I choose them for a given project.

Flask and Django has build in webserver,
this is good for working/testing local and building a web application.

When finish and want to deploy to web,
then think of(shall i use Gunicorn,Tornado,uWSGI or running mod_wsgi (Apache)?
Host like Pythonanywhere,Heroku make it easier to deploy Python code.

commented: great answer +14

Hi snippsat,

Thank you so much for your answer. There is a little misunderstand there, I guess. Here are detailed questions again.

  • In the first question, ctually asking which directory on linux should I choose to place a project? Like /home/user/ or /var/www etc?

  • In the 3rd question, you said you'd use something like Gunicorn,Tornado,uWSGI or Apache. The question how do you decide between so many options. When do you want to use Gunicorn & when do you prefer mod_wsgi on Apache like that?

Thank you, once again. :)

In the first question, ctually asking which directory on linux should I choose to place a project? Like /home/user/ or /var/www etc?

Where I should put my python scripts in Linux?.

In the 3rd question, you said you'd use something like Gunicorn,Tornado,uWSGI or Apache. The question how do you decide between so many options. When do you want to use Gunicorn & when do you prefer mod_wsgi on Apache like that?

I like Gunicorn easy to setup,and default options works good for most cases.
I you search eg: Gunicorn vs uWSGI you get a lot of opinions.

Look at Full Stack Python,there is a lot of info on deploy and run a Python web application.
For smaller personal projects you don't have to think to much about the deploy side.
For bigger commercial sites there is a lot of tought/work on the deploy side.

commented: awesome +0

Thank you very much. Not sure how I missed that post on stackoverflow.

I've seen the Full stack python, it also gives you many options to choose & but not how do I choose them. Thank you for suggestion gunicorn. I'll go with it for now as I'm not gonna build any large applications soon. :)

I've seen the Full stack python, it also gives you many options to choose & but not how do I choose them

Yes it can be confusing,Nginx + Gunicorn,Tornado,uWSGI?
Here is little info about Heroku and PythonAnywhere.

@Heroku
Do Python applications run behind Nginx?
So on Heroku you do not use Nginx,you just have to setup a server like Gunicorn.
You see how in Getting Started with Python on Heroku

PythonAnywhere is very easy,and do like all deploy stuff for you.
You use UI and upload files and do a coulpe of config choices.
Then you have website,and PythonAnywhere run that site with,
Nginx to do routing and uWSGI to run the apps.

That's great information. Thank you very much. :)

I'm gonna start with nginx+gunicorn on DigitalOcean for my first basic flask app.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.