473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

the way of "import"


I have three files names t1.py,t2.py,t3.py in e:\test\dir1,of course
dir2 is exsit
the content of t1.py as follow:
t1.py
import os
print 'this is t1.py'
os.chdir('..\\dir2')
the content of t2.py as follow:
print "this is t2.py"
the content of t3.py as follow:
import t1
import t2
if i run t3.py in cmd of windows as follow:
python t3.py

no errors show

if i run t3.py in idle:
>>import t3
this is t1.py
Traceback (most recent call las
File "<stdin>", line 1, in <module>
File "t3.py", line 2, in <module>
ImportError: No module named t2

can you give me a help?
Mar 8 '08 #1
1 1414
En Sat, 08 Mar 2008 00:30:13 -0200, smalltalk <tt******@gmail.com>
escribi�:
I have three files names t1.py,t2.py,t3.py in e:\test\dir1,of course
dir2 is exsit
the content of t1.py as follow:
t1.py
import os
print 'this is t1.py'
os.chdir('..\\dir2')
the content of t2.py as follow:
print "this is t2.py"
the content of t3.py as follow:
import t1
import t2
if i run t3.py in cmd of windows as follow:
python t3.py

no errors show

if i run t3.py in idle:
>>>import t3
this is t1.py
Traceback (most recent call las
File "<stdin>", line 1, in <module>
File "t3.py", line 2, in <module>
ImportError: No module named t2

can you give me a help?
Which Python version? Which Windows version? With IDLE from Python 2.5.1
on XP I don't get the error (and that's the right thing)

--
Gabriel Genellina

Mar 9 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vio | last post by:
Hi, I've been trying to embed (statically) wxPy alongside an embedded py interpreter on a linux/gtk box. At one point, for some reason misc.o linking reported "multiple definitions of...
2
by: Tian | last post by:
I am writing a python program which needs to support some plug-ins. I have an XML file storing some dynamic structures. XML file records some class names whose instance needs to be created in the...
9
by: monkey | last post by:
I just learn to make a blank windows frame with python and wxpython. I found the statment "import wx" cannot work as the original "from wxPython.wx import *". I see in the readme file of wxpython...
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
1
by: Xiao Jianfeng | last post by:
Hello, In pymol I can use "from chempy import Atom" but "import chempy.Atom" doesn't work. It says,"ImportError: No module named Atom". What is going wrong ? Thanks
3
by: Mudcat | last post by:
I have a directory structure that contains different modules that run depending on what the user selects. They are identical in name and structure, but what varies is the content of the functions....
3
by: Chris | last post by:
Hi, 1) In file test.aspx, i put: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %> <%@ import namespace="System.Data"%> <%@ import...
5
by: mark_galeck_spam_magnet | last post by:
Hi, why does complain name 'compileFile' not defined. But works. Why? (I did read the tutorial, it seems to say "import module" should work. Thank you, Mark
1
by: Eric Hanchrow | last post by:
(This is with Python 2.5.2, on Ubuntu Hardy, if it matters.) This seems so basic that I'm surprised that I didn't find anything about it in the FAQ. (Yes, I am fairly new to Python.) Here are...
3
by: J. Cliff Dyer | last post by:
On Thu, 2008-05-08 at 12:00 -0700, Eric Hanchrow wrote: It's the same reason as this: 5 5 6 5 Python "variables" are just names that point at objects. When you
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.