[Numpy-discussion] Crash on (un-orthodox) __import__
Thu Oct 6 16:25:18 CDT 2011
On Tue, Oct 4, 2011 at 3:04 AM, Andrea Gavana <firstname.lastname@example.org> wrote:
> Hi All,
> I was fiddling here and there with some code doing dynamic import of
> stuff, and I noticed that this code:
> import os
> import sys
> init_name = r"C:\Python27\Lib\site-packages\numpy\__init__.py"
> directory, module_name = os.path.split(init_name)
> main = os.path.splitext(module_name)
> sys.path.insert(0, os.path.normpath(directory))
> # Crash here...
> mainmod = __import__(main)
in this case, your main is '__init__' and your directory is
'C:\Python27\Lib\site-packages\numpy' which is probably not what you
intended. You should make directory 'C:\Python27\Lib\site-packages'
and main into 'numpy'
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
More information about the NumPy-Discussion