I can't run django server nor activate the virtualenv

647 views
Skip to first unread message

Fred DJar

unread,
Apr 28, 2014, 6:03:40 AM4/28/14
to django...@googlegroups.com
Hello guys, i'm a newbie so bear with me :)

I have installed python 2.7 and django 1.6 on my desktop (ubuntu 14)
but i can't run the application or activate the virtualenv


this is the message i got:
ubuntu@ubuntu:~/Downloads/saf$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 280, in execute
    translation.activate('en-us')
  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 130, in activate
    return _trans.activate(language)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)

Victor Hooi

unread,
Apr 28, 2014, 6:34:35 AM4/28/14
to django...@googlegroups.com
Hi Fred,

Are there any lines below the error message you pasted?

The last line I can see is:

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module 
    __import__(name)

Is there anything else?

Cheers,
Victor

Fred DJar

unread,
Apr 28, 2014, 6:41:42 AM4/28/14
to django...@googlegroups.com
There is one other line:
ImportError : No module named bootstrapform

Rene Zelaya

unread,
Apr 28, 2014, 9:59:39 AM4/28/14
to django...@googlegroups.com
Hi Fred -

So if you can't activate your virtualenv, and you installed Django in that virtualenv, that is likely the root of your problem, because without it, none of the modules will appear as installed and you will not be able to run the server (or access the python manage.py shell, etc).  I would first figure out why you can't activate the virtual environment -- what is the error when you try to activate it?

Rene

Fred DJar

unread,
Apr 28, 2014, 10:10:29 AM4/28/14
to django...@googlegroups.com
Thanks Rene
The virtualenv was created in Ubuntu but now i'm running windows, should i run it in Ubuntu because i've noticed that virtualenv folder structure differentiate from Ubuntu to windows
this is the message i got from the prompt command: activate is not recognized as an internal or external command, operable program or batch file

Rene Zelaya

unread,
Apr 29, 2014, 9:35:39 AM4/29/14
to django...@googlegroups.com
Hi Fred,

Yes, definitely, I think you should run it on a Ubuntu terminal - I'm not that familiar with the Windows terminal

Fred DJar

unread,
May 1, 2014, 4:25:42 PM5/1/14
to django...@googlegroups.com
Iv'e run it on ubuntu terminal but still not working

Lee

unread,
May 1, 2014, 6:03:25 PM5/1/14
to django...@googlegroups.com
Please be more specific about your problem as its difficult to help when we don't know exactly what you are seeing. Have you managed to activate your virtualenv on ubuntu? If not, what specific error are you getting?

I see two problems here so far, regarding the import error, that means you are missing a dependency of the project you are trying to run. But that may just be that you've not activated your virtualenv - though you need to install the dependencies there once you get virtualenv running anyway most likely. The 'activate is not recognized as an internal or external command, operable program or batch file' error just means the activate script  was not found. You have to either be in the location where the activate script is, or else you need to specify the path to it, which will be in the bin folder of wherever you created the virtualenv. 

BTW, not wanting to confuse matters, but virtualenvwrapper is a useful addition on Linux, but its worth understanding virtualenv first.

Fred DJar

unread,
May 1, 2014, 6:39:39 PM5/1/14
to django...@googlegroups.com

Thank you for your response 
i've made a screenshot to illustrate clearly what happening

btw i'm not familiar with virtualenv in ubuntu i've only used it on windows and in order to activate the virtualenv i just run the activate the command.
maybe this is not the case in ubuntu!! maybe it should be run from the bash. if so can you tell me how because i have no idiea



On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:

Lee

unread,
May 1, 2014, 7:21:01 PM5/1/14
to django...@googlegroups.com
Enter the following command from the bin folder:

source activate

Thanks

On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:

Fred DJar

unread,
May 1, 2014, 7:28:50 PM5/1/14
to django...@googlegroups.com
Lol, thanks that was super easy
but now i have another problem, i'm missing some packages even though i'm in the virtualenv

here is a screenshot demonstration

 


On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:

Lee

unread,
May 1, 2014, 7:53:25 PM5/1/14
to django...@googlegroups.com
Next command: pip install -r requirements

From the directory where the requirements file is of course... And assuming the requirements file has all the requirements of whatever you are trying to run in it

Lee

unread,
May 1, 2014, 8:05:20 PM5/1/14
to django...@googlegroups.com
Also be aware that from the stack trace, it looks like you have django installed into the global site packages rather than your virtualenv. The main point of virtualenv is to avoid that and have isolated environments. But it's not really a problem as long as you are aware of the fact that you are using the global site packages

Fred DJar

unread,
May 1, 2014, 8:12:54 PM5/1/14
to django...@googlegroups.com
so i'm in the directory /usr/local/lib/python2.7/dist-packages/django/core/management
and now i should run the command pip install -r requirements 
and replace requirements with the missing file (for example base.py) 
is that it??

i'm sorry if my questions seems dumb

Fred DJar

unread,
May 1, 2014, 8:13:36 PM5/1/14
to django...@googlegroups.com
yes i know because i've installed django before trying to work the virtualenv problem

Lee

unread,
May 2, 2014, 2:52:24 AM5/2/14
to django...@googlegroups.com
No, you were in the right locatin before. Look at your last screenshot. There was a file called requirements and you do it from there. If it does not work, please confirm what is in that requirements file

Fred DJar

unread,
May 2, 2014, 9:29:49 AM5/2/14
to django...@googlegroups.com


I've got an error message running the last command. here is the screenshot

Andreas Kuhne

unread,
May 2, 2014, 9:48:15 AM5/2/14
to django...@googlegroups.com
You are not running your commands in a virtual environment. You can't run pip outside the virtual environment because that requires root permissions. If you type "sudo pip install -r requirements", it will install the files, but I'm not sure you want to do that. 

Every shell you open, you have to run "source activate" from the bin folder. Otherwise you will be running on the systems default.

So before you write "pip install -r requirements", make sure you are in the bin folder and write "source activate".

Regards,

Andréas

--
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/fea28e89-1b67-475d-8959-a345cdb65473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Kuhne

unread,
May 2, 2014, 9:50:12 AM5/2/14
to django...@googlegroups.com
You can always see if your shell is running with a virtual environment, by the (env) in front of the prompt. If you check your last screenshot, you will see that you are running in a virtualenvironment there.

Regards,

Andréas
Message has been deleted

Fred DJar

unread,
May 2, 2014, 11:13:03 AM5/2/14
to django...@googlegroups.com

I got this error message trying to fetch the requirements 





On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:

Lee

unread,
May 2, 2014, 6:26:43 PM5/2/14
to django...@googlegroups.com
So it looks like its uninstalling the Django you already have installed in the global packages, in order to install the version specified in the requirements file, but is hitting a permissions error in doing so because you are not logged in as root (or elevating with sudo). I presume your virtualenv was set up using global site packages if its picking that up. So you have 2 options.

1) Elevate your permissions to delete the existing django in the site root with the following command (im not sure if you need to deactivate your virtualenv or not to do that since I never install anything globally):

sudo pip uninstall django
Enter your password when prompted

Then with your virtualenv activated try the previous command again:

pip install -r requirements

2) delete your virtualenv, and create a new one, specifying no site packages so you have an isolated virtualenv rather than the one you have now:

rmvirtualenv env

Then the following to create the new one, activate it and then install your requirements:

mkvirtualenv --no-site-packages env
source activate (from the bin folder as usual)
pip install -r requirements

Thanks


On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:

Fred DJar

unread,
May 2, 2014, 7:23:03 PM5/2/14
to django...@googlegroups.com
Trying your first solution gave me this error messages !



And trying the second solution gave me the message that rmvirtualenv : command not found !

Lee

unread,
May 2, 2014, 7:54:05 PM5/2/14
to django...@googlegroups.com
Whoops sorry, should have thought, rmvirtualenv and mkvirtualenv come with virtualenvwrapper, not the default virtualenv...

Regarding the first error, was that the whole error or was there some more after where the screenshot cut off? Looks like it tried to install django that time so I guess the uninstall of the global version helped to some extent. 

Regarding the second option, ignore deleting the existing virtualenv (though you can just delete the original directories it created for it if you like) for now and just create a new one with a different name with the following:

virtualenv --no-site-packages newenvname

activate it as before then try running pip install -r requirements again  

Fred DJar

unread,
May 3, 2014, 11:25:57 AM5/3/14
to django...@googlegroups.com
Thanks
the second solution worked fine and the requirements were installed

but again when i tried to run the server this is what i got



On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:

Lee

unread,
May 3, 2014, 11:59:01 AM5/3/14
to django...@googlegroups.com
Can you copy the complete error across? The end of it is all important and its chopped off in the screenshot. 

Thanks

Lee

unread,
May 3, 2014, 12:05:29 PM5/3/14
to django...@googlegroups.com
Actually, its probably the same problem as from the start as I see your install from the requirements file only installed Django itself and nothing else. THerefore I presume it does not have a list of all the dependencies you need. Assuming the last error was again "ImportError : No module named bootstrapform", it looks like your project might be using django-bootstrap-form from a quick google. So try the following with your virtualenv active:

pip install django-bootstrap-form

BTW, what is this project you are trying to run. GIven it seems to have external dependencies that you are not aware of, I assume its not your code? If so, I would expect wherever you got it from to have a list of the dependencies that the project needs to run (though usually they would be in the requirements file too)

Thanks

Fred DJar

unread,
May 3, 2014, 1:44:27 PM5/3/14
to django...@googlegroups.com
the boostrapform was installed correctly but there's still some problems
as you said this is not my code, and i will try to contact the guy who write the code and get the missing dependencies 

Fred DJar

unread,
May 3, 2014, 3:03:55 PM5/3/14
to django...@googlegroups.com
FINALLY 
the server is running

the problem was is two dependencies django-userena and django-bootstrap-form. and the userena dependency was relying on another dependency which is six (the core of the problem) because it didn't installed automatically when installing userena so i had to install it separately


I CAN't THANK YOU ENOUGH LEE
THANK YOU VERY MUCH FOR YOUR TIME


On Saturday, 3 May 2014 17:05:29 UTC+1, Lee wrote:

Lee

unread,
May 3, 2014, 4:23:07 PM5/3/14
to django...@googlegroups.com
You are welcome, glad it helped :)
Reply all
Reply to author
Forward
0 new messages