0

[Linux Mint]

Linux Mint

I'm following a book on Django and it has this -> https://hellowebapp.com/setup/ accompanying website. Take a look below at what I'm getting when I get to the "Start your Django project" section of the link.

Here's a peak at my terminal input and feedback.

(venv) user@mothership myhellowebapp $ pip install Django==1.9.6
Collecting Django==1.9.6
Downloading Django-1.9.6-py2.py3-none-any.whl (6.6MB)
100% |████████████████████████████████| 6.6MB 138kB/s
Installing collected packages: Django
Successfully installed Django-1.9.6
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv) user@mothership myhellowebapp $ git init
Initialized empty Git repository in /home/user/projects/python/django-projects/myhellowebapp/.git/
(venv) user@mothership myhellowebapp $ django-admin.py startproject hellowebapp .
django-admin.py: command not found
(venv) user@mothership myhellowebapp $ ls
venv
(venv) user@mothership myhellowebapp $ python django-admin.py startproject hellowebapp .
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
(venv) user@mothership myhellowebapp $ ls

Note that I already have python 2.7 & 3.5 installed on my system and when referring to python my system is by default pointing to python 2.7. Any ideas?

2
Contributors
7
Replies
42
Views
10 Months
Discussion Span
Last Post by lewashby
1

Try which pip and which python. Both should be in your virtual env's bin directory. django-admin.py should be in the same directory. You can also use locate django-admin.py to find all the files with that name in your file system.

0

I'm not completely sure how a venv works but I'm guessing the which python & which pip shouldn't be returning an absolute path from root the way they are below. I'm assuming that they should be displaying relative paths from the either the project directory or the venv directory but I don't know for sure

   user@mothership myhellowebapp $ source venv/bin/activate
    (venv) user@mothership myhellowebapp $ which python
    /usr/bin/python
    (venv) user@mothership myhellowebapp $ which pip
    /usr/bin/pip
    (venv) user@mothership myhellowebapp $ locate django-admin.py
    /home/user/.local/bin/django-admin.py
    /home/user/.local/bin/django-admin.pyc
    /home/user/.local/lib/python2.7/site-packages/django/bin/django-admin.py
    /home/user/.local/lib/python2.7/site-packages/django/bin/django-admin.pyc
    /home/user/.local/share/Trash/files/NewerFiles/orig/.local/share/Trash/expunged/3117399120/build/lib/django/bin/django-admin.py
    /home/user/.local/share/Trash/files/NewerFiles/orig/.local/share/Trash/expunged/3117399120/build/scripts-3.3/django-admin.py
    /home/user/.local/share/Trash/files/NewerFiles/orig/.local/share/Trash/expunged/3411875491/build/lib.linux-x86_64-2.7/django/bin/django-admin.py
    /home/user/.local/share/Trash/files/NewerFiles/orig/.local/share/Trash/expunged/3411875491/build/scripts-2.7/django-admin.py
    (venv) user@mothership myhellowebapp

I don't think I bothered to try and install python or pip to the virtual environment but thought I would just use my system wide python and pip for that and instead focust on just installing django localy to the venv. But even when I tried to install python and pip localy to the venv to see if that was the problem this is what I got.

(venv) user@mothership myhellowebapp $ sudo apt-get install python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python is already the newest version (2.7.11-1).
0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
(venv) user@mothership myhellowebapp $ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-pip is already the newest version (8.1.1-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
(venv) user@mothership myhellowebapp $
1

This is strange, there should be a python interpreter in the virtualenv's bin/ directory. Didn't you create the virtualenv with a python interpreter such as in

virtualenv --python=python2.7 mydir

?

1

You should be using the python interpreter and the pip command from your venv bin/ directory. What's in your venv's bin directory ?

Edited by Gribouillis

0
user@mothership myhellowebapp $ source venv/bin/activate
(venv) user@mothership myhellowebapp $ ls -l venv/bin
total 3508
-rw-r--r-- 1 user user    2125 Dec 20 22:35 activate
-rw-r--r-- 1 user user    1067 Dec 20 22:35 activate.csh
-rw-r--r-- 1 user user    2265 Dec 20 22:35 activate.fish
-rw-r--r-- 1 user user    1137 Dec 20 22:35 activate_this.py
-rwxr-xr-x 1 user user     295 Dec 20 22:35 easy_install
-rwxr-xr-x 1 user user     295 Dec 20 22:35 easy_install-2.7
-rwxr-xr-x 1 user user     267 Dec 20 22:35 pip
-rwxr-xr-x 1 user user     267 Dec 20 22:35 pip2
-rwxr-xr-x 1 user user     267 Dec 20 22:35 pip2.7
lrwxrwxrwx 1 user user       7 Dec 20 22:35 python -> python2
-rwxr-xr-x 1 user user 3546104 Dec 20 22:35 python2
lrwxrwxrwx 1 usr user       7 Dec 20 22:35 python2.7 -> python2
-rwxr-xr-x 1 user user    2384 Dec 20 22:35 python-config
-rwxr-xr-x 1 user user     274 Dec 20 22:35 wheel
0

I just followed the exact same steps from the website again only in a new directory and now everything is working fine. Go figure. Thanks Grib.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.