*On 11/21/12 5:58 AM, Luisa Beck wrote:**
*
*Thank you for your thoughts! I have a few follow-up questions: *
*
*
*The reason that I’m trying to figure out postgres is that I’m helping
some folks with a development project and they’re using postgres. I’m
trying to do the tutorial with that so that I can get familiar with
postgres and the pgAdmin III interface. And also with how Django,
Python and Postgres work together (your explanation has been very
helpful with that).
Regarding your explanations:
I have a bash “Terminal” and an SQL Shell. I also have virtual
environments in a folder ~/Sites/django_test (i.e. when I tell the
bash Terminal to “activate” this folder, it puts me in a an (env)).
However ,when I run “python manage.py runserver" at the bash Terminal
command line, I get an error message saying “can't open file
'manage.py': [Errno 2] No such file or directory”.
Even when I run the command in the (env), I get the error message:
/Library/Frameworks/Python.framework/Versions/3.2/Resources/Python.app/Contents/MacOS/Python:
can't open file 'manage.py': [Errno 2] No such file or directory(Which
I presume is telling me that the path is still set on an incorrect
version of Python (3.2), even though I want to use version 2.7 and
trashed the 3.2 version from my system. )
*
*It sounds like you have a damaged virtual environment. They are easy to
build so just create a new one.**
**
**For the Mac I'm using MacPorts to get packages, and virtualenv to
build my python environment. I highly recommend both. MacPorts puts
packages underneath /opt/local so you can figure out where something is
located (the Apple packages are harder to track down imo). Install
py27-virtualenv and py27-pip from MacPorts and that should get you the
basics, including python 2.7. Make sure that /opt/local/bin is in your
path. Create your virtualenv using "virtualenv-2.7". Use pip to grab
python packages once you have your basic virtualenv created and activated.**
*
I think that there are a few gaps in my understanding here:
* I don’t understand the difference between typing in commands into
my bash Terminal versus my SQL shell
*"SQL shell" is pgAdmin? In any case, they are just two different
environments, where for the latter case you are talking directly to your
database server.**
*
* Is running “python manage.py runserver” the same as running Python
programs with an IDE like IDLE?
*Probably not, but in any case follow the tutorial using your terminal
windows.**
*
* How and where do I adjust your $PATH environment variable so that
the correct python occurs first on the path?
*Your ~/.bashrc file is the place to put in path changes appropriate for
all of your work. Adjust the path e**lsewhere if you only want the path
changed sometimes.**
hth
- Tom
*
* I think that I installed the correct Python version into the
virtual environment using pip install. Why am I still receiving a
“No such file or directory” error?
* Why does Python version 3.2 still appear in the path indicated by
my error message is I trashed it?
If you could help me with these questions, or simply list links with
any tutorials that explain this, that would be much appreciated. Or
perhaps you know how I can access ‘freenode’ so that I can ask in the
discussion forum? Thanks!
Also, I'm having trouble entering freenode because it says
that "#Django Cannot join channel (+r) - you need to be
identified with services"
And lastly, if someone could forward me a tutorial about how
the databases, python files,
virtual environments and Django work together (I am new to all
of these) that would be much appreciated!
Thanks in advance!
Luisa
I'm no Mac expert, but I'll offer a couple of thoughts.
First, you shouldn't need to solve both the PostgreSQL
installation issue and learning Django at the same time. sqlite3
is adequate to the tutorial, and is built in to modern pythons
(e.g.; 2.7), and I presume that's true on the Mac as well.
Django is written in Python, which requires no pre-compilation,
but must be run with a python interpreter, e.g.; "python manage.py
runserver" at the command line. The tutorial is written with the
assumption that you will be running it from the command line. If
you have more than one python installed on your system, you can
specify which one to use by including the path on the command
line, such as "~/bin/python manage.py runserver", or you can
adjust your $PATH environment variable so that the correct python
occurs first on the path. This last is what virtualenv does: the
activate code (which you must "source", not run, e.g.; "source
~/venvs/djtutorial/bin/activate") adjusts the PATH (and prompt) of
the shell that sources it so that the virtualenv's python is found
first*, and defines a "deactivate" shell function that will undo
the changes (exiting the shell is just as good - i.e., this will
not last across a reboot, you must activate each new shell -
command line window - that you start to work on this project).
Python figures out where you ran it from, and searches from there
for it's libraries, and finds first those associated with the
virtualenv, e.g. "~/venvs/djtutorial/lib/python2.7/". This means
that you can install things there (e.g.; by using "pip install
..." from a shell that has been activated for that virtualenv) and
they won't effect your base python installation.
[ * Perhaps not commonly understood, you don't need to activate if
you specify the path to the correct python, e.g.;
"~/venvs/djtutorial/bin/python manage.py runserver", so it is easy
to create a shell script or even an alias that does your most
common stuff. For example, you might make a copy of manage.py,
maybe called "manage", add a first line with the magic incantation:
#!/absolute/path/to/the/correct/python
Then make that file executable ("chmod a+x manage") and you will
be able to do "./manage runserver", etc., whether or not you have
activated in the current shell. (I specifically recommend against
putting the project directory on your path, thus the "./" part.) ]
For most databases Django connects to the database's socket to
communicate. For sqlite3 the code is running within your python
interpreter and it reads and writes the specified file for
persistence. Django's ORM maps models onto database tables and
the fields of the model onto the columns of the table, and
provides the "syncdb" command for initializing the tables.
*-- **
**You received this message because you are subscribed to the Google
Groups "Django users" group.**
**To view this discussion on the web visit
**https://groups.google.com/d/msg/django-users/-/Any7ms_MjRMJ**.**
**To post to this group, send email to django-users@googlegroups.com.**
**To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.**
**For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.**
*
*
*
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.