diff options
-rw-r--r-- | docs/faq.rst | 14 | ||||
-rw-r--r-- | docs/getting.rst | 4 | ||||
-rw-r--r-- | pyvisa/errors.py | 35 |
3 files changed, 37 insertions, 16 deletions
diff --git a/docs/faq.rst b/docs/faq.rst index 28da727..11796e2 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -60,12 +60,24 @@ Error: No matching architecture ------------------------------- This error occurs when you the Python architecture does not match the VISA -architecture. It is common on Mac OS X and the error message looks like this:: +architecture. + +.. note:: PyVISA tries to parse the error from the underlying foreign function + library to provide a more useful error message. If it does not succeed, it + shows the original one. + + In Mac OS X the original error message looks like this:: OSError: dlopen(/Library/Frameworks/visa.framework/visa, 6): no suitable image found. Did find: /Library/Frameworks/visa.framework/visa: no matching architecture in universal wrapper /Library/Frameworks/visa.framework/visa: no matching architecture in universal wrapper + In Linux the original error message looks like this:: + + OSError: Could not open VISA library: + Error while accessing /usr/local/vxipnp/linux/bin/libvisa.so.7:/usr/local/vxipnp/linux/bin/libvisa.so.7: wrong ELF class: ELFCLASS32 + + First, determine the details of your installation with the help of the following debug command:: python -c "from pyvisa import util; util.get_debug_info()" diff --git a/docs/getting.rst b/docs/getting.rst index c36dfa2..64b91b6 100644 --- a/docs/getting.rst +++ b/docs/getting.rst @@ -7,6 +7,10 @@ PyVISA is a wrapper around the `National Instruments's VISA` library, which you PyVISA has no additional dependencies except Python_ itself. In runs on Python 2.6+ and 3.2+. +.. warning:: PyVISA works with 32- and 64- bit Python and can deal with 32- and 64-bit VISA libraries without any extra configuration. What PyVISA cannot do is open a 32-bit VISA library while running in 64-bit Python (or the other way around). + + **You need to make sure that the Python and VISA library have the same bitness** + You can install it using pip_:: $ pip install pyvisa diff --git a/pyvisa/errors.py b/pyvisa/errors.py index 42a9365..87d4519 100644 --- a/pyvisa/errors.py +++ b/pyvisa/errors.py @@ -426,24 +426,29 @@ class LibraryError(OSError, Error): msg = str(exc) - s = 'Error while accessing %s:' % filename - if ': image not found' in msg: - s += ' File not found or not readable.' + msg = ' File not found or not readable.' elif ': no suitable image found' in msg: if 'no matching architecture' in msg: - details = util.get_system_details(visa=False) - visalib = util.LibraryPath(filename, 'user' if filename == util.read_user_library_path() else 'auto') - s += ' No matching architecture.\n' - s += ' Current Python interpreter is %s bits\n' % details['bits'] - s += ' The library in: %s\n' % visalib.path - s += ' found by: %s\n' % visalib.found_by - s += ' 32bit: %s\n' % visalib.is_32bit - s += ' 64bit: %s' % visalib.is_64bit + return LibraryError.from_wrong_arch(filename) else: - s += ' Could not determine file type.' - else: - s += str(exc) + msg = 'Could not determine filetype.' + + elif 'wrong ELF class' in msg: + return LibraryError.from_wrong_arch(filename) + + return cls('Error while accessing %s: %s' % (filename, msg)) - return cls(s) + @classmethod + def from_wrong_arch(cls, filename): + s = '' + details = util.get_system_details(visa=False) + visalib = util.LibraryPath(filename, 'user' if filename == util.read_user_library_path() else 'auto') + s += 'No matching architecture.\n' + s += ' Current Python interpreter is %s bits\n' % details['bits'] + s += ' The library in: %s\n' % visalib.path + s += ' found by: %s\n' % visalib.found_by + s += ' bitness: %s\n' % visalib.bitness + + return cls('Error while accessing %s: %s' % (filename, s)) |