我读了很多关于问题的帖子,但没有一个能解决我的问题。虽然我一直在关注this blog但是当我尝试运行一个示例src python文件时仍然会出现此错误:
Traceback (most recent call last):
File "facility.py", line 25, in <module>
import cplex
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/__init__.py", line 43, in <module>
import callbacks
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/callbacks.py", line 48, in <module>
from _internal._aux_functions import apply_freeform_two_args, apply_freeform_one_arg
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/__init__.py", line 22, in <module>
import _list_array_utils
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_list_array_utils.py", line 13, in <module>
import _pycplex as CPX
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex.py", line 19, in <module>
_pycplex_platform = swig_import_helper()
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex.py", line 15, in swig_import_helper
_mod = imp.load_module('_pycplex_platform', fp, pathname, description)
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex_platform.py", line 23, in <module>
from cplex._internal.py1013_cplex1251 import *
ImportError: dlopen(/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/py1013_cplex1251.so, 2): no suitable image found. Did find:
/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/py1013_cplex1251.so: mach-o, but wrong architecture
不幸的是我不熟悉/.bash_profile,但是我在最后添加的链接中发布了什么。 有人可以帮助我吗?
答案 0 :(得分:1)
一个可能的解决方案是检查是否可以手动将cplex目录复制到已安装的站点包(您可能需要使用sudo)。
从你的堆栈跟踪我看到你已经安装了cplex /用户/ SB /应用/ IBM / ILOG / CPLEX_Studio1251 / CPLEX /蟒/ x86_darwin /
首先在交互式shell中运行(我假设你是python 2.7):
import site; site.getsitepackages()
有关此步骤的详细信息,请参阅How do I find the location of my Python site-packages directory?。
这将为您提供需要复制&#34; cplex&#34;的网站包的目录。目录到。我假设它是/Library/Python/2.7/site-packages from here
然后在Mac上运行:
sudo cp -r ./cplex /Library/Python/2.7/site-packages/
这会将cplex手动设置为python安装的可导入包。因此,您应该能够在python交互式shell中导入cplex。