tutorial
tutorial copied to clipboard
Stop using a virtualenv
Currently we install a virtualenv which is considered a best practice, but maybe a bit too complex for beginners. Nowadays you can use pip install --user Django for a good enough result.
Before I start to work on this, I'm interested in some feedback.
That's an interesting proposal. My first reaction was negative, as I want to teach my students best practices whenever I can and now using virtualenv comes natural to me.
But I remember that when I was learning, I didn't really understand the magic behind (myvirtualenv) in cmd and it added to the confusion when I was opening new terminal window and things were not working anymore.
What about deployment? Doesn't running it on PythonAnywhere require creating a virtualenv?
I stumbled on Ola's answer to issue #489. She wrote there:
I think it's gives students a powerful feeling if you can say to them at the end: "today you used tools I use everyday in my job, there is nothing that will surprise you now", and we very much wanna stick to this, even if it means we need to explain more things :)
That's also a powerful argument for virtualenv to stay.
what about pipenv? It's waaay easier to use for setting up an environment :
pip install pipenv # install pipenv
mkdir blog && cd blog # make and enter folder
pipenv --python 3 # create environment using python3
pipenv install django # install django on environment
pipenv shell # enter enviroment
django-admin startproject mysite .
python manage.py migrate
python manage.py runserver
@onlurking I like using the very modern way. It's good to be teaching the latest tools but I must admit not being that modern yet. Would you be able to come up with a patch?
Sure @ekohl, I could write a draft but it will need revision since english isn't my mother language.
pipenv I haven't used yet but some people like it, some people hate it, may be a bit too young/new to start recommending it?
pip install --user is good but sometimes fails to give you usable binaries if you don't have your §PATH set correctly (eg on default debian/ubuntu, and also on windows, depending on how you install python)
For some users, our tutorial isn't the first Django tutorial they attempt, so they may have newer versions (e.g., currently 2.0) installed globally or for their user than the DjangoGirls tutorial assumes (currently 1.11).
Continuing to use a dedicated virtual environment (no matter whether created by virtualenv ..., python3 -m venv or pipenv --python 3 or tools from virtualenvwrapper or yet others) for the DjangoGirls tutorial avoids breaking their projects they created in these other tutorials and it avoids breaking their project they'll create in the DjangoGirls tutorial when they later do other tutorials.
Simply doing (or having done) several tutorials doesn't necessarily mean that these participants are advanced enough to figure that potential breakage and its fixes out for themselves, so IMHO we should continue to guide them through at least the basics, as we already do: Using one virtual environment per project.
Hi,
Beginner here.
I have received multiple errors when attempting to run python3 -m venv myvenv, some of which send me down a never ending rabbit hole trying to locate a solution for Windows 10.
The easiest alternative found was doing the following (as @onlurking has suggested):
$ pip3 install --user pipenv
$ pipenv install django
$ pipenv shell
I think it would also be handy to add details on downloading install Homebrew and Chocolately just in case or maybe offering alternative versions of the tutorial (e.g. Beginner, Intermediate, Advance).
In addition, for me personally, the installing packages with requirements is also a little more complicated.
Count me among the lovers of pipenv. In fact, I found this issue because I was going to file an issue suggesting the switch.
I switched two years ago after seeing a presentation at PyCon Cleveland (or maybe the PyCon before that one. I loose track.)
It's been very well-behaved for me.
Also, I've convinced a high school teacher (and published author of a Python book) and his students to make the switch, and he's now in love with it as well.
More recently I heard a lot of doubts about pipenv and I'm personally also not sure I like it. The last release is more than a year old and I've seen concerns about its maintenance. Not sure we should be switching over.