Issues with virtualenv


#1

So I finished all the chapters except deploying . I made a mistake , I was having issues with virtualenv earlier so I didn’t use it and made the app without it since I was gonna use it just locally ,so is there any way I can like ‘migrate’ the whole app (this hello web app) into a virtualenv now? Or will I have to make it all over again?


#2

The issue now is that everything is installed globally on your computer, but as long as you create virtualenvs for future projects, shouldn’t be that big of an issue.

Have you been creating your requirements.txt? If you create a virtualenv for your project now and activate it, you can run pip install -r requirements.txt, and that’ll go through and install everything into your new env, then you can go forward with Heroku. Shouldn’t take that long!

If you need help creating the virtualenv, let me know if you’re on Mac, PC, or Linux. :)


#3

So I go into the top project folder,and then create a virtualenv and then create requirements.txt? Will that work?

Also, I’m on Linux (Ubuntu ) :)
Thanks for the reply!


#4

Yeah, go into your top-level project folder (the one with manage.py). Run virtualenv venv in your command line (if that doesn’t work, make sure virtualenv is installed on your computer - pip install virtualenv, then do what I said before). Then “activate” the environment by running source venv/bin/activate.

It should put a (venv) at the front of your command line, like this:

(venv)limedaring@Orion ~/projects/hellowebapp $

(Orion is my personal computer name, it’ll look different for you but still will have (venv) in front.)

You can deactivate the environment by running deactivate. I keep a “cheat sheet” to remind me of these commands, highly recommend doing so too. :) (I really should make a printable for Hello Web App-ers, shouldn’t I? Hmm.)

Let me know if that works!


#5

Yes, it worked perfectly ,thanks :)
And I’m getting that line,so what next ?


#6

Everything installed? Your app still working locally? Is your requirements.txt filled out according to the book? If so, you can continue with launching on Heroku, as it’ll install on your production server everything that’s listed in requirements.txt.


#7

Well, everything is installed and the app is working but since I made the virtualenv AFTER making the whole app, my requirements.txt is showing the following instead of just those 3 things in the book :
http://pastebin.com/dVLG84LQ/

Should I continue with launching on Heroku ?


#8

No — erase everything in your requirements.txt, as all of those things will be installed on your Heroku server and you don’t want that. You only want the stuff you need for your app in your requirements.txt.


#9

Ok,thanks :)
One more thing, when I make the next app and use virtualbox from the beginning,will I have to install all the stuff again ?

Sorry for the noobish question,this is my first time with something like this :s


#10

Yup :) Which is important because project 1 and project 2 will probably have different things installed, and, if project 2 is built later than project 1, the stuff you install might change versions (Django 1.9 rather than Django 1.8). For compatibility, you want to keep them separate. :) If you were making apps by using globally installed stuff, you might add something that’ll interfere with other things you have installed and then all of your local apps would break, not just the one you’re working on.


#11

Thanks a lot :D!
Btw ,did you make this website using Python and Django :D?


#12

This forum? Alas no — forums are hard and they are SUCH magnets for spam, so I went with Discourse (http://www.discourse.org/) which has spam protection built in. :) I know my limits, I definitely couldn’t build this myself, hah!


#13

Okay, but this is still super cool though :D!