Newbie: Complete environment setup(virtualenv, pip, eclipse, git...)

431 views
Skip to first unread message

Martin Torre Castro

unread,
Jul 19, 2014, 9:41:11 PM7/19/14
to django...@googlegroups.com
Hello,

my name is Martin and I'm a computer engineer from Spain. I'm going to start a new project with a colleague and I decided to use Django because we searched for free opensource tools and I'm in love with Python.

We have made a couple of tutorials (the official one and "Tango with django"). I've also bought the book "Two scoops of Django" for the 1.6 Django edition. We're starting the project soon as well as we finish the design, but I'm concerned about setting up the new environment. We're thinking of using:

  • postgresql
  • Python/Django [ of course ;-) ]
  • Eclipse/Pydev
  • Git
  • jQuery
I've been reading the Greenfield/Roy book and some web sites and I want to set up the environment with good practices by using virtualenvwrapper, virtualenv, pip, the requirements.txt files and so on.
I have made some mix for all this, but I would be grateful if someone could confirm us if we are on the right way, give us some advice or maybe tell us where on the internet we can find a good way of doing all this.

My preview for the whole setting up is next:

  1. We should start the installations by installing "sudo apt-get install virtualenvwrapper" . If I understand correctly, this installs virtualenv as well as an embedded pip.
  2. The virtualenv must be created ("virtualenv env") in the parent directory of the Eclipse workspace, I suppose. This is one point of confusion to me. I don't know either if I have to activate this every time I come back for developing resuming the work from days before. I completely understand that later from Eclipse I will give the python path inside the virtualenv, but don't know if must activate the virtualenv every time.
  3. Next step would be to install all the things we need (django, pillow, psycopg2) using a requirements.txt file. "pip install -r requirements.txt"
  4. We should create the new django project with a python django-admin.py startproject <project_name>
  5. Now I don't know if we should link the project to an already installed version of Eclipse or run the "git init" first. I understand that Eclipse and Git don't need to be installed inside the virtualenv. In fact, I've been reading and it seems that Eclipse can work OK just by being given the path inside the virtualenv where the python executable is located. I've also read that some people used to make different workspaces, but configuring the paths should be enough http://stackoverflow.com/questions/1145374/virtualenv-with-eclipse-galileo
From here I would just upload to github or bitbucket, maybe doing the whole thing from Eclipse would be easier. But the integration with Eclipse when we made tangowithdjango tutorial was the difficult point, because there is no option for importing a django project from Eclipse (Kepler version last time). We found easier to create the project from Eclipse, but we were not using a virtualenv for the tutorial.

I haven't used virtualenv before, so it's our second main obstacle, but I expect it will be easy when we get used to it (^_^) .

Please could someone help with some piece of advice, pros and cons of every option. Just don't want to do something now I will regret in future.

Thank you veeery much in advance.

PS: Some links visited:

Thomas Lockhart

unread,
Jul 19, 2014, 10:29:53 PM7/19/14
to django...@googlegroups.com
On 7/19/14 6:41 PM, Martin Torre Castro wrote:
Hello,

my name is Martin and I'm a computer engineer from Spain. I'm going to start a new project with a colleague and I decided to use Django because we searched for free opensource tools and I'm in love with Python.

We have made a couple of tutorials (the official one and "Tango with django"). I've also bought the book "Two scoops of Django" for the 1.6 Django edition. We're starting the project soon as well as we finish the design, but I'm concerned about setting up the new environment. We're thinking of using:

  • postgresql
  • Python/Django [ of course ;-) ]
  • Eclipse/Pydev
  • Git
  • jQuery

All good choices. pip and virtualenv provide for a reproducible and robust installation. PostgreSQL is imho far superior to other options for db. I don't have experience with using Eclipse in this environment so can't comment there.

hth

                               - Tom

Martin Torre Castro

unread,
Jul 21, 2014, 2:40:52 AM7/21/14
to django...@googlegroups.com
Firstly, I want to say "thank you" to you, Thomas.

Secondly, could you or someone how does the development cycles work with virtualenv? Is this way of working just as I wrote? 

I think it works by activating the virtualenv every time with a "source activate" command and after that starting to program from the terminal. I need to know this for adapting Eclipse to activating the virtualenv every times it opens if virtualenv works as expected.

Thanks

Phang Mulianto

unread,
Jul 21, 2014, 2:50:59 AM7/21/14
to django-users
Hi Martin,

Virtualenv is use for using different version of python or python library so it wont use the default python in system.  So when open eclipse for editing, no need to activate virtualenv, but when you need to run the code in specific python install, you need to activate virtualenv.

VIrtualenv will be usefull in production , where several different python version needed or several python libarary with different version used.

Regards,

Mulianto




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f99612a0-0d8f-44ee-93ee-2ed3e01055f3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

ngangsia akumbo

unread,
Jul 21, 2014, 2:55:39 PM7/21/14
to django...@googlegroups.com
If you are working with windows , let me give you a very simple guide.
Google and download setuptools.exe and install in to your computer.

First install python 2.7 ans set the python path
Then move to this directory C:\Python27\scripts in the windows command .
You should run easy_install pip
Then also run easy install virtualevn and your virtual env will be install in that directory alone.

Then to create you environment you run this command
virtualenv --no-site-packages [name of your environment]
for example virtualenv --no-site-packages django_test

Then to activate this environment you type this command
[name of your enviroment]\scripts\activate   make sure you do all this in that directory abovee

for example
C:\Python27\scripts\django_test\scripts\activate
then your environment will be activated

Then move to this directory cd django_test
you path will become C:\Python27\scripts\django_test.

Then run pip install django [you can specify the version]

then when django is install move to the directory as so
run the dir command you will see the downloaded django

move to the downloaded django as using this command

cd Django-1.4.3 depending on the version of your django
To install the django now in to the system , type

setup.py install in this directory C:\Python27\scripts\django_test\Django-1.4.3. That will depend your directory

django will be install
then move to cd django
C:\Python27\scripts\django_test\Django-1.4.3\django

move to C:\Python27\scripts\django_test\Django-1.4.3\django\bin\

the u will have to create your projects

run this command withtin that sam directory

C:\Python27\scripts\django_test\Django-1.4.3\django\bin\django-admin.py startproject [name of your project]


Then you can figure out the rest
Thanks



Tom Evans

unread,
Jul 21, 2014, 3:01:02 PM7/21/14
to django...@googlegroups.com
Hi Martin

Everything you've said seems on the right path. For your couple of queries:

You need to activate the virtualenv each time you want to run python
within that environment. You simplify this by putting the path to the
environment in to Eclipse as this also 'activates' the environment, so
that every time you run something through Eclipse you do not need to
first activate the environment.

Typically, you would need to activate the environment to do things
like run your project from the command line, or install python
packages in to the environment.

Another useful technique I use is to have a "bootstrap" script, a
simple shell script that installs a virtualenv if it does not already
exist, activates that environment; and then installs or upgrades all
the packages listed in requirements.txt. This script can then be run
whenever to ensure the environment is up to date and correct.

#!/bin/sh
if [ ! -d env ]; then
virtualenv env
fi
ln -sf ./env/bin/activate
. ./activate
pip install --upgrade -r requirements.txt

Give your projects differently named environments - don't call them
all 'env', or you will inevitably install something in the wrong env.

When writing your requirements file, you can track security releases
of libraries by specifying like this:

django>1.6<1.7

This would install the latest security release in the 1.6 line of
django, and every time you re-run bootstrap, it will install any newer
1.6 security release of django, but will not auto-install the 1.7
version (which has plenty of API changes and could break your site).
You should still upgrade your libraries, but on your terms!

Hope that helps!

Cheers

Tom

Martin Torre Castro

unread,
Jul 21, 2014, 4:07:06 PM7/21/14
to django...@googlegroups.com
Thanks Mulianto, ngangsia and Tom.

I'm working in Ubuntu but I will take advantage of your instructions ngangsia when setting up all the "machinery".

Thanks also Tom, for the advice and the requirements tip, as this will be another thing we're trying for the first time in future.

Ezequiel

unread,
Jul 22, 2014, 1:55:14 PM7/22/14
to django...@googlegroups.com
On Saturday, July 19, 2014 10:41:11 PM UTC-3, Martin Torre Castro wrote:
Please could someone help with some piece of advice, pros and cons of every option. Just don't want to do something now I will regret in future.
Thank you veeery much in advance.


Hi Martín,
Just one suggestion: replace Eclipse with Pycharm (has a free edition) which (I think) has better virtualenv support and is a better IDE for Django/Python projects.

Regards,
Ezequiel.

Babatunde Akinyanmi

unread,
Jul 22, 2014, 2:29:47 PM7/22/14
to Django users


On 22 Jul 2014 18:56, "Ezequiel" <ediazp...@gmail.com> wrote:
>
> On Saturday, July 19, 2014 10:41:11 PM UTC-3, Martin Torre Castro wrote:
>>
>> Please could someone help with some piece of advice, pros and cons of every option. Just don't want to do something now I will regret in future.
>> Thank you veeery much in advance.
>>
>
> Hi Martín,
> Just one suggestion: replace Eclipse with Pycharm (has a free edition) which (I think) has better virtualenv support and is a better IDE for Django/Python projects.
>

+1

> Regards,
> Ezequiel.
> http://flickrock.com/mikelpierre


>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.

> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/95ee4123-ba1b-41a1-b78f-b4ced9e4da70%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages