Weird import problem

A

Anton81

I have a directory structure like

NS/dir1/file1.py
NS/dir2/file2.py

if in the python shell I type

import NS.dir1.file1

it works, however typing

import NS.dir2.file2

fails with

ImportError: No module named dir2.file2

Any ideas what could go wrong?
Directory permissions seem to be OK.
 
D

Diez B. Roggisch

Anton81 said:
I have a directory structure like

NS/dir1/file1.py
NS/dir2/file2.py


This *must* be wrong or at least not the full directory listing - please
read

http://docs.python.org/tut/node8.html
if in the python shell I type

import NS.dir1.file1

it works, however typing

import NS.dir2.file2

fails with

ImportError: No module named dir2.file2

Any ideas what could go wrong?
Directory permissions seem to be OK.

Missing __init__.py in the dir2?

Diez
 
A

Anton81

NS/dir1/file1.py
This *must* be wrong or at least not the full directory listing - please
read
It is the directory structure in one of the python paths.
Missing __init__.py in the dir2?
Oh right. I forgot about this. Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Module import via sys.path and py2exe 2
is this a good way to do imports ? 1
the way of "import" 1
circular import Module 9
Import problem 8
importing a package 4
python import error 7
Problem with Packages 3

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top