error messages unclear
Chad Netzer
cnetzer at mail.arc.nasa.gov
Tue Dec 3 21:35:19 EST 2002
On Tuesday 03 December 2002 17:05, Paul G. wrote:
> Hi folks,
>
> Keep getting this, and am still not exactly sure how to decode it.
>
> > AttributeError: 'module' object has no attribute 'path'
[snip snippity snip snip]
> Finally, the auto-traceback adds this:
>
> File ".../python-2.2.1/Lib/distutils/sysconfig.py", line 23, in ?
> PREFIX = os.path.normpath(sys.prefix)
For the sake of answering the direct question you posed (about how to
'decode' the error message), the 'os' module is a standard one (included in
your distribution), and a standard component of that module is the 'path'
submodule. Somehow, the python you are running cannot find the 'path'
submodule. All the stuff about 'normpath' is a red herring; the os module
itself somehow doesn't have 'path' and THAT is exactly what the error is
telling you. It needs 'path' before it can resolve 'normpath'
Now, having a broken 'os' module like this probably means your installation
is kind of messed up. So, let's move on for a bit...
> Here is the complete text of the error:
>
> $ make
> gcc -o python.exe \
> Modules/python.o \
> libpython2.2.a -lm
[snip]
> Traceback (most recent call last):
> File "./setup.py", line 7, in ?
> from distutils import sysconfig
> File "\msys\1.0\src\python-2.2.1/Lib/distutils/sysconfig.py", line 23, in
> ? PREFIX = os.path.normpath(sys.prefix)
> AttributeError: 'module' object has no attribute 'path'
[snip]
> AttributeError: 'module' object has no attribute 'path'
>
> really is saying nothing that might help in terms of what the actual cause
> of the error in fact "is".
Yes, it is all there. I'll get to that.
> os.path.normpath(sys.prefix) is not verbalized, nor is it, apparently,
> defined to be constant for any system.
Not sure what you mean, but I can tell you that 'os' is a module that should
come installed with any Python distribution. A submodule of 'os' is 'path'
that has services like 'normpath'. Yours is messed up, so that there is no
'path' and hence no 'normpath'. For example, in a working install, you would
be able to do something like this (I'm on unix, but it'll work similarly for
windows):
$ python
Python 2.2.2 (#1, Nov 21 2002, 08:18:14)
>>> import sys
>>> import os
>>> os.path
<module 'posixpath' from '/usr/lib/python2.2/posixpath.pyc'>
>>> os.path.normpath(sys.prefix)
'/usr'
If I delete os.path, I will get the error you saw:
>>> del os.path
>>> os.path.normpath(sys.prefix)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'path'
So, the only question is why is your Python installation messed up?
> I am not using Cygwin.
So, looking again at the compile line, it would appear that you are in fact
trying to build Python under windows, using gcc that is not a cygwin gcc...
Am I correct? Do you already have an installed python distribution? I am
assuming you are on Windows, because your paths have mixed "\" and "/"
characters in them, although it also appears you are trying to use a
"unix-like" build environment (make/gcc/etc.) Furthermore, you are building
a python.exe, which implies you are building the Python executable. But, you
are also using a python.exe to do the build (ie, "./python.exe -E ./setup.py
-q build;;").
Now, not having built python on Windows at all, much less using a "unix-like"
environment, I'm not sure what is going on. But my guess is that somehow
everything is just getting hosed, either because you are overwriting the
environment with an incomplete one, or something else.
So, that should explain the "why" of both the error message, and the
underlying cause of the build error message. But without knowing more about
what you are trying to build, and what tools you are using, I can only give
speculative fixes. If you just want to run Python, you should download some
Python executables for Windows (there are various types, with installers,
etc.) If you want to build python yourself, and already have a working
python, you need to be careful about your paths when building, I suspect.
Others have done the same, so post more details and people can probably help.
If you ARE using Cygwin (which I suspect you are, and the above was a typo),
then I'm pretty sure Cygwin already has a pre-built Python. Did you want to
compile that with different options.
Finally, if you are not building python at all, then the error text you
posted seems very confusing indeed.
In any case, I know this is a verbose message, and that you are probably
frustrated after some time looking through code and trying to build your
program (or python environment). But, with some more specific information
about what you are trying to accomplish (ie. build python on Windows using
gcc and make), I'm sure people will be able to help.
--
Bay Area Python Interest Group - http://www.baypiggies.net/
Chad Netzer
cnetzer at mail.arc.nasa.gov
More information about the Python-list
mailing list