473,837 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12433
Thanks for posting.

pythonpath = .;c:\maxq\bin\t estScripts; c:\maxq\bin;c:\ maxq\jython

Both files are in c:\maxq\bin\tes tScripts. 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 ("nCreateIncide nt")
test.Run()

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

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

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

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

Best Regards,

jvh

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

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

That should be:

if __name__ == "__main__":
t = nBaseTest('nBas eTest')
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
2605
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 empty module object. That works okay, but as soon as the generated code tries do perform certain imports, it fails! Certain other imports succeed. Consider this example code:
2
3543
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 call last): File "dbmod.py", line 2, in ? File "odbc.pyo", line 9, in ?
1
1596
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 updates. My problem is that any script that tries to import cgi.py breaks. For example, the following script: #!/usr/bin/python print """Content-type: text/html\n\n"""
3
2315
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 formatter File "/home/geir/programmering/htmlparse/formatter.py", line 2, in -toplevel- import htmllib
10
2128
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 donot know what is i ? why?
0
2498
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 application It gives the error ImportError: cannot import name QtCore. .. I tries the trunk from the snv, but it still gives the same error. I also would like to know. if there are any report generation tool i can use with python similar to crystal...
3
5150
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.. Cannot import this Web Part. at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean clearConnections) at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean...
2
2185
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 T_STRING in C:\wamp\www\test\hi.php on line 16 <?php
0
1562
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 error: cannot import a Python module 'nox.coreapps.switch.pymyswitch': ImportError: No module named switch.pymyswitch
0
9682
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10870
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10563
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10621
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7804
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5668
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4038
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.