473,397 Members | 1,949 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,397 software developers and data experts.

cannot import name .....


Greetings.

What is the implication of the error message 'cannot import
name .....'? It occurs when executing the line:

from nBaseTest import nBaseTest

The file exists and the class within it exists. Changing it to

from nBaseTest import x

gives me the same result so it is as though the class does not exist.
Thought there may be a problem with the nBaseTest file but standalone
it runs fine.

Thus my earlier question. Maybe I should ask where find detailed error
information.

Thanks,

jvh

May 3 '07 #1
2 12400
Thanks for posting.

pythonpath = .;c:\maxq\bin\testScripts; c:\maxq\bin;c:\maxq\jython

Both files are in c:\maxq\bin\testScripts. Also I do not get the
message "no module named...:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File nCreateIncident.py, the importer:

from PyHttpTestCase import PyHttpTestCase
from com.bitmechanic.maxq import Config
global validatorPkg
from nBaseTest import nBaseTest

# definition of test class
class nCreateIncident(nBaseTest):
def runTest(self):
self.msg('Test started')
self.logon()

# Code to load and run the test
if __name__ == 'main':
test = nCreateIncident("nCreateIncident")
test.Run()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File nBaseTest

from PyHttpTestCase import PyHttpTestCase
from com.bitmechanic.maxq import Config
global validatorPkg
if __name__ == 'main':
validatorPkg = Config.getValidatorPkgName()
# Determine the validator for this testcase.
exec 'from '+validatorPkg+' import Validator'
# definition of test class
class nBaseTest(PyHttpTestCase):
def logon(self):
self.msg('Test started')

if __name__ == 'main':
t = nBaseTest('nBaseTest')
t.logon()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Best Regards,

jvh

May 3 '07 #2
I do see one problem there...

if __name__ == 'main':
t = nBaseTest('nBaseTest')
t.logon()

That should be:

if __name__ == "__main__":
t = nBaseTest('nBaseTest')
t.logon()

It should be like that in both files.

May 3 '07 #3

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

Similar topics

4
by: Irmen de Jong | last post by:
Hello, I don't understand why the following doesn't work. What I want to do is dynamically import some generated Python code and I'm doing this using compile and exec'ing it in the dict of a new...
2
by: Marc Ederis | last post by:
Hello, I'm trying to create an executable with py2exe, and it uses the odbc module. The script runs fine until I use py2exe on it and run the ..exe. Then I get: -- Traceback (most recent...
1
by: yazzoo | last post by:
I've been banging my head over a long running script that has suddenly stopped working when my ISP upgraded Apache and Suexec. They didn't specify what they did, but I presume it was the latest...
3
by: geir.smestad | last post by:
Using Ubuntu Breezy Badger 5.10. I get the following traceback: ----- Traceback (most recent call last): File "/home/geir/programmering/htmlparse/formatter.py", line 1, in -toplevel- import...
10
by: Jia Lu | last post by:
Hi all: I try to do things below: import i Traceback (most recent call last): File "<pyshell#67>", line 2, in <module> import i ImportError: No module named i But it seems that import...
0
by: asoft | last post by:
Please i need help with this. I just started using python and i hace run into several issues. The on that i can't tackle is the issue of no being able to compile the python code using PyQt4...
3
by: srig | last post by:
hi.. i have created a web part which will display data from sql server 2005.while i run it in visual studio 2003 there s no error..when i deploy it in sharepoint site im gettin followin error.. ...
2
by: kkshansid | last post by:
cannot import table in mysql 1i saved my excell file in csv formate 2i made a data base in mysql 3i made a table with 5 fields 4i run this file error Parse error: syntax error, unexpected...
0
by: Anna Butt | last post by:
Hi, I have a problem with a module in python. When I try to execute it I have this error: 00019|nox|ERR:Cannot change the state of 'pymyswitch' to INSTALLED: 'pymyswitch' ran into an...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.