Home Help Center

Python: Import Problem

GodEmperorGodEmperor Member Andrew ZellerOrganization: The Laboratory for Laser Energetics of UoRProject: Using Ice services for web services/applications
Hey there,

I'm fairly new to both Python and Ice, but it's what my employers use for their services (and I can understand why, having read a vast majority of the manual it's a pretty useful tool) and my supervisor wants me to code in Python as it's what the group that'll be using the services I'm working on uses or something to that effect. All I know for sure is he thinks python would be best for a web application in line with the Ice services up and running.

However, I seem to be having problem with my Python in the import way. At first it wasn't finding Ice, simple enough, needed to set the path toward the location of the Python. I, however, think I might have done this wrong as it also is giving me a problem with IcePy. I was wondering if there was any help on this. I've looked around, but most seem to be slightly different to my problem (as I tried those suggestions and it did nothing, or maybe I just missed something).

For reference: I do have Visual Studios 2005 installed on my work computer and the locations of it, Ice, and Python are here

C:\Python26
C:\Program Files\ZeroC\Ice-3.4.1
C:\Program Files\Microsoft Visual Studio 8

For the error:

before I tried changing the path
import Ice
Traceback <most recent call last):
    File "<stdin>", line 1, in <module>
ImportError: No module named Ice

after I tried changing the path
import Ice
Traceback <most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\Program Files\ZeroC\Ice-3.4.1\Python\Ice.py", line 47, in <module>
        import IcePy
ImportError: DLL load failed: The specified module could not be found.

Any help would be greatly appreciated, and I'm sure I'll have other questions as I move along in my project, but I'll be sure to keep searching for the answer before I bother you with more questions. Thanks :)

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Andrew,

    Welcome to the forum.

    It sounds like your PATH isn't correct. Did you add the bin subdirectory of the Ice installation to your PATH?

    For example:

    PATH=C:\Program Files\ZeroC\Ice-3.4.1\bin;%PATH%

    Regards,
    Mark
  • GodEmperorGodEmperor Member Andrew ZellerOrganization: The Laboratory for Laser Energetics of UoRProject: Using Ice services for web services/applications
    C:\Program Files\ZeroC\Ice-3
    .4.1\bin;C:\Python26;C:\Program Files\ZeroC\Ice-3.4.1\Python;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Perl\site\bi
    n;C:\Perl\bin;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\WINDOWS\system32\Win
    dowsPowerShell\v1.0;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\orac
    le\product\10.2.0\client_2\bin;C:\Program Files\MATLAB\R2010a\runtime\win32;C:\P
    rogram Files\MATLAB\R2010a\bin;Pñ↕

    That's what I get when I echo out path. Still having an import problem though. I did add the bin directory you suggested. Am I missing something else? Sorry if there's a kinda silly simple solution, I tend to miss the silly simple as I over think the concepts and the code itself, often forget how important the environment actually WORKING can be.
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    I tried to reproduce your situation in a Windows XP virtual machine. This VM has VS2005 installed (even though the Ice 3.4.1 binary distribution for Windows requires VS2008 or later), and not much else. I installed the Python 2.6.5 MSI from python.org and the Ice 3.4.1 installer. Then I did the following:

    C:\> set PATH=C:\Python26;C:\Program Files\ZeroC\Ice-3.4.1\bin;%PATH%
    C:\> set PYTHONPATH=C:\Program Files\ZeroC\Ice-3.4.1\python
    C:\> python
    Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import Ice
    >>>

    Importing the Ice module works fine here, so I suspect you still have an environmental issue.

    Which Python distribution are you using?

    Regards,
    Mark
  • GodEmperorGodEmperor Member Andrew ZellerOrganization: The Laboratory for Laser Energetics of UoRProject: Using Ice services for web services/applications
    Ah ha! There we go, the line

    "set PYTHONPATH=C:\Program Files\ZeroC\Ice-3.4.1\python" I must have set it wrong before, but it works now. Wonder what it was I missed before. Thanks :) (I think I didn't add the Python part to the line).

    Edit: though it's odd, I realized that setting my paths isn't persisting, that might be another cause of my woes with this. I'm going to have to talk with the computer guys around here about this as they're the ones who control how much power I have over my own computer here (sadly).

    While this is still open, if it's checked, which version of Ice has 2005 specific examples for Ice? I.e. the demos are built for VS 2005 so I can learn more about Ice through example in a language I'm far more comfortable with (C++) while I learn to use Python and slowly merge what I've learned between the two. I think my biggest problem here is trying to learn Python and more about Ice at the same time.
Sign In or Register to comment.