Django
Scott Haneda
talklists at newgeo.com
Sat Jan 23 01:39:30 PST 2010
On Jan 22, 2010, at 11:09 PM, Jasper Frumau wrote:
> On Sat, Jan 23, 2010 at 6:26 AM, Scott Haneda <talklists at newgeo.com> wrote:
>
>> Do what Daniel suggested in the beginning of this thread.
>> First, test with the full path, so run:
>>
>> /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py
>> startproject
>> on the command line.
>
> OK, I did (And read some more about $PATH):
>
> Jaspers-MacBook-Pro:~ jasper$ sudo
> /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py
> sudo: /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py:
> command not found
>
>> If that works,
I am not sure how the command can not be found, since it was called implicitly. How about we try a few other things, keeping in mind, I know nothing about django.
Though this is interesting:
http://dl.dropbox.com/u/340087/drops/01.23.10/django-9cc2b400-011835.png
If google auto complete is any indication that others are having the same issue, and I can estimate that those "others" are more than likely not ports users, this seems to be a Django issue.
The first hit in google:
http://code.djangoproject.com/wiki/InstallationPitfalls
I am not sure I agree with that solution. Even though you do not have the Django bin in your path, we called it direct. Lets try a different method:
$cd /opt/local/lib/python2.4/site-packages/django/bin/
$ls -la
What does that report? Just the line for 'django-admin.py' will suffice, I want to see the permissions.
While in the above bin directory, assuming the file is +x, so the rwx's in the first column, end in an 'x', what happens when you run:
$sudo ./django-admin.py
If the file is not executable:
$cd /opt/local/lib/python2.4/site-packages/django/bin/
$sudo cp django-admin.py django-admin.fix.py
$sudo chmod +x django-admin.fix.py
Also strange, this trac note states the same about the PATH:
http://code.djangoproject.com/ticket/4679
Looking over some more notes, it does look as though people are symbolic linking their Django stuff into some place that their PATH looks. You may want to give this a try, since of the above links, and two more, that is working for them:
sudo ln -s /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py /opt/local/bin/
>> then add the django bin to your path, which is probably in one of the do
>> files in ~
>> Try this:
>> $cd ~
>> $grep PATH ~/.profile
>
> Jaspers-MacBook-Pro:~ jasper$ grep PATH ~/.profile
> # MacPorts Installer addition on 2009-10-20_at_13:11:20: adding an
> appropriate PATH variable for use with MacPorts.
> export PATH=/opt/local/bin:/opt/local/sbin:$PATH
> # Finished adapting your PATH environment variable for use with MacPorts.
I am not sure how I feel about altering PATH to add just a Django point to it, so the `ln -s` may be a better method, and seems to be the more suggested method. Though from the above, we can tell that your PATH is defined in ~/.profile, which means, if you wanted to add Django's bin to that path, you would insert /opt/local/lib/python2.4/site-packages/django/bin: just before the trailing $PATH
Example:
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/python2.4/site-packages/django/bin:$PATH
>> Also try other files that start with a dot, like .bashrc
>
> Jaspers-MacBook-Pro:~ jasper$ grep PATH ~/.bashrc
> Jaspers-MacBook-Pro:~ jasper$ cat ~/.bashrc
> alias mysqlstart='sudo /opt/local/bin/mysqld_safe5'
> alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
I just learned the other day about the `port load` and `port unload` commands, which save you the aliasing, and are quite handy.
$sudo port load mysql5
$sudo port unload mysql5
-- same works for Apache2 also --
I imagine the same works for any "startup item" driven port software that has been installed. Very handy indeed.
>> and .bash_profile
>
> Not found
There was a lengthy discussion about the difference in the various .profile, .bashrc, .bash_profile and other simialr files here on the mailing list a few months back. I was the thread starter. Perhaps you can find it in the archives, as I learned a ton from it. You do not need .bash_profile though. It was just a check to see where your PATH has been set at.
> Yes I will. Normally do so, but forgot to last night...
>
>> * On a side note, could one just symblink
>> /opt/local/lib/python2.4/site-packages/django/bin to /opt/local/bin and save
>> the hassle of an increasingly long PATH? I have added apache's bin to mine,
>> and a few others. I am not sure how I feel about the symblinking, but
>> wanted to know if it wold work.
>
> Well symlink as in:
>
> A symbolic link path2 is created to path1 (path2 is the name of the file
> created, path1 is the string
> used in creating the symbolic link). Either name may be an arbitrary
> path name; the files need not be
> on the same file system.
>
> would be good but the real path does not seem to work either:
That could be Django specific, or permissions or execute bit issues. It seems a common problem based on the evidence above.
> Jaspers-MacBook-Pro:~ jasper$ sudo
> /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py
> Password:
> sudo: /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py:
> command not found
> Jaspers-MacBook-Pro:~ jasper$ sudo cd
> /opt/local/lib/python2.4/site-packages/django/bin/
I do not think you an sudo a `cd`, which is why you did not actually change directory and are still in your home dir (~). Try `sudo -s` which will put you in a postion to not have to `sudo` every command, as well as maintain your current ENV.
> Jaspers-MacBook-Pro:~ jasper$ ls
> ABC Downloads Pictures TextMate-Projects
> Apartment-One Library Public Webbills
> Desktop Movies Sites Webdesign
> Documents Music Storage www.kinkfm.com
Your `cd` command did not work.
> Jaspers-MacBook-Pro:~ jasper$ cd
> /opt/local/lib/python2.4/site-packages/django/bin/
> Jaspers-MacBook-Pro:bin jasper$ ls
> __init__.py daily_cleanup.py make-messages.py
> unique-messages.pyc
> __init__.pyc daily_cleanup.pyc make-messages.pyc
> compile-messages.py django-admin.py profiling
> compile-messages.pyc django-admin.pyc unique-messages.py
Ok, I guess I should have read the entire email before starting the reply :) I will leave the rest of the noise I typed above there though, as it does offer suggestions on permissions that could be related. Ignore the bits where you have already `cd`'d into the correct directory.
> Jaspers-MacBook-Pro:bin jasper$ django-admin.py
> -bash: django-admin.py: command not found
This one you are probably going to need to `sudo` unless you are still in `sudo -s` which you will be able to tell because the shell will say 'root' for the username.
I would start hitting up google and also the Django mailing lists, as this is pretty clearly not a MacPorts issue, from what I can tell.
--
Scott * If you contact me off list replace talklists@ with scott@ *
More information about the macports-users
mailing list