473,668 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

module check

Can anybody suggest a correct way of checking in python module exists
and correctly installed from python program.

Jan 22 '07 #1
3 1857
I'm at work so I can't test this, but I do beleive the inspect module
can help you out. If it can't you can always try import the module
in a try-catch statement, catching ImportError, however ImportError may
be raised if the module you imported has trouble loading another
module, but it shouln't be to hard to track down where the ImportError
came from, a traceback object can give a lot more information than you
would beleive.
Victor Polukcht wrote:
Can anybody suggest a correct way of checking in python module exists
and correctly installed from python program.
Jan 22 '07 #2
I'm at work so I can't test this, but I do beleive the inspect module
can help you out. If it can't you can always try import the module
in a try-catch statement, catching ImportError, however ImportError may
be raised if the module you imported has trouble loading another
module, but it shouln't be to hard to track down where the ImportError
came from, a traceback object can give a lot more information than you
would believe.
Victor Polukcht wrote:
Can anybody suggest a correct way of checking in python module exists
and correctly installed from python program.
Jan 22 '07 #3
Victor Polukcht wrote:
Can anybody suggest a correct way of checking in python module exists
and correctly installed from python program.
Not sure I understand the question, but I'll try:

try: import yourmodule
except:
print "Can't import yourmodule"
-Larry
Jan 22 '07 #4

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

Similar topics

2
1731
by: Marcus Schneider | last post by:
I use PythonWin on WinXP. Every time I change a module, I have to leave PythonWin and re enter to make it notice I have made changes. I guess this is not the normal way to do that.. do I have to store the module at a specific place? Is there a kind of "reset" command to make the main module update specific data?
2
1561
by: Jim Jewett | last post by:
I have often wanted to pass arguments to a module. Tyically, these are globals, such as DEBUG or VERBOSE that are set at the top of the module -- and I want to use a different value. For modules that provide a service (such as logging), I would like to make my changes before the defaults are set up. Assuming that the loaded module is cooperative, what is the least ugly way to pass these parameters?
8
2075
by: Grant D. Watson | last post by:
If this has been answered before, or if my terminology is off, please bear with me; my Python experience is limited to use in one class and to personal projects. I'd like to do something rather silly: I'd like to run a particular piece of code from a given module every time that the module is imported, and not just at the time that the module is originally loaded. So, every time a module says import foo or something analogous, I want...
18
3034
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of a single collections type, I should be proposing a new "namespaces" module instead. Some of my reasons: (1) Namespace is feeling less and less like a collection to me. Even though it's still intended as a data-only structure, the use cases...
7
14379
by: Guy Robinson | last post by:
Hello, I have a directory of python scripts that all (should) contain a number of attributes and methods of the same name. I need to import each module, test for these items and unload the module. I have 2 questions. 1.. How do unload an imported module? 2.. how do I test for the existance of a method in a module without running it?
4
8458
by: livin | last post by:
my log... INFO urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'Action': 'hs.ExecX10ByName+Kitchen+Lights%2C+On %2C+100&x=4&y=6'})) INFO INFO File "Q:\python\python23.zlib\urllib.py", line 78, in urlopen INFO File "Q:\python\python23.zlib\urllib.py", line 159, in open INFO File "Q:\python\python23.zlib\urllib.py", line 957, in splittype INFO AttributeError
5
2152
by: Johann C. Rocholl | last post by:
The following is my first attempt at adding a taint feature to Python to prevent os.system() from being called with untrusted input. What do you think of it? # taint.py - Emulate Perl's taint feature in Python # Copyright (C) 2007 Johann C. Rocholl <johann@rocholl.net> # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the...
8
3751
by: dmitrey | last post by:
howto check does module 'asdf' exist (is available for import) or no? (without try/cache of course) Thx in advance, D.
21
34389
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
0
182
by: norseman | last post by:
mercado mercado wrote: =================================== I started to import a module using its path and now see what you mean. Python is missing the concept: Programmer dictates what machine does. (I come from assembly. If the hardware can do it, so can I.) sys.path can be modified to switch between file sets (prod/test). if a global is set one way, use the normal paths,
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
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
8893
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
8656
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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
4205
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...
1
2791
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
2023
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.