Unexpected exception when activating MATLAB R2009a or earlier on Mac Pro

http://www.mathworks.com/support/solutions/en/data/1-8GS5S1/index.html

Subject:

Why do I get an unexpected exception when activating MATLAB 7.8 (R2009a) or earlier on a Mac OS X machine?

Problem Description:

When I attempt to activate MATLAB on Mac OS X, I get the error:
There was an unexpected exception:
null
See the log file (/tmp/aws.log) for more details.
The log file has the following information:
MATHWORKS ACTIVATION IS STARTING UP.
java.lang.UnsatisfiedLinkError: Cant load library: /Applications/MATLAB_R2008b.app/bin/maci64/libinstutil.jnilib
com.mathworks.instutil.NativeUtility.(NativeUtility.java:36)
com.mathworks.instutil.MachineInfo.(MachineInfo.java:40)
com.mathworks.activationclient.model.ActivationModelImpl.loadNativeLib(ActivationModelImpl.java:216)
com.mathworks.activationclient.model.ActivationModelImpl.getMachineInfo(ActivationModelImpl.java:189)
com.mathworks.activationclient.view.ApplicationViewImpl.getMachineInfo(ApplicationViewImpl.java:200)
com.mathworks.activationclient.view.ApplicationViewImpl.showGUI(ApplicationViewImpl.java:79)
com.mathworks.activationclient.controller.ApplicationControllerImpl.start(ApplicationControllerImpl.java:99)
com.mathworks.activationclient.ActivationApplication.main(ActivationApplication.java:31)
null
com.mathworks.activationclient.view.ApplicationViewImpl.showGUI(ApplicationViewImpl.java:79)
com.mathworks.activationclient.controller.ApplicationControllerImpl.start(ApplicationControllerImpl.java:99)
com.mathworks.activationclient.ActivationApplication.main(ActivationApplication.java:31)
How can I activate MATLAB on Mac OS X?

Solution:

This issue is due to a change in the default Java version from when MATLAB R2009a was released. The activation may attempt to call 64 bit libraries, whereas MATLAB is a 32 bit application under Mac OS X. As a workaround, you can temporarily change your system's default java for applications to use the 32-bit JVM. Once you have activated, you can change it back to Java 6 (64-bit) or J2SE 5 (64-bit).

To do this, open the Java Preferences application from /Applications/Utilities/Java/Java Preferences (early 10.5 releases) or /Applications/Utilities/Java Preferences (10.6).

Make sure you are under the "General" Section, and if there are multiple lists, the "Java Applications" list will be modified. In the section marked "Java Applications", drag the 32-bit item to the top of the list. Then close this application and restart the activation client by double clicking on the MATLAB application in your Applications directory.

`Unexpected exception formatting exception. Falling back to standard exception` 这个错误通常表示在格式化异常信息时又出现了意外异常,因此程序只能回退到标准的异常处理方式。以下是一些可能的解决方法: #### 检查日志记录配置 很多时候,这个错误和日志记录配置有关。如果日志格式化字符串里有无效的占位符,或者在格式化日志消息时发生了异常,就会出现该错误。要确保日志格式化字符串正确,占位符和传入的参数匹配。 ```python import logging # 配置日志 logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO) try: # 模拟一个异常 result = 1 / 0 except Exception as e: # 记录异常信息 logging.error('An error occurred: %s', e) ``` #### 检查自定义异常类 要是代码里有自定义异常类,要确保这些类的 `__str__` 或 `__repr__` 方法实现正确。如果这些方法里出现异常,在格式化异常时就会触发该错误。 ```python class CustomException(Exception): def __str__(self): try: # 这里可以实现自定义的异常信息格式化 return f"Custom exception: {self.args[0]}" except IndexError: return "Custom exception with no arguments" try: raise CustomException("Something went wrong") except CustomException as e: print(e) ``` #### 捕获并记录内部异常 在捕获异常时,可以捕获内部异常并记录下来,这样有助于定位问题。 ```python try: # 模拟一个异常 result = 1 / 0 except Exception as e: try: formatted_error = f"An error occurred: {e}" except Exception as inner_e: import traceback traceback.print_exc() print(f"Inner exception: {inner_e}") else: print(formatted_error) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值