在MacOS上使用Python3的cvxopt

2024-10-01 07:10:58 发布

您现在位置:Python中文网/ 问答频道 /正文

使用pip安装cvxopt包后,导入该包不起作用:

% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H15
% python3 --version
Python 3.7.2
% pip3 install cvxopt 
Collecting cvxopt
  Using cached cvxopt-1.2.6-cp38-cp38-macosx_10_9_x86_64.whl (3.1 MB)
Installing collected packages: cvxopt
Successfully installed cvxopt-1.2.6
% cat testcvxopt.py 
import cvxopt

print("hi")
% python3 testcvxopt.py 
Traceback (most recent call last):
  File "testcvxopt.py", line 1, in <module>
    import cvxopt
ModuleNotFoundError: No module named 'cvxopt'

我已经阅读并尝试了有关安装cvxopt的大部分内容,但没有找到任何有效的方法。有什么建议吗?谢谢


Tags: pippyimportosmacswpython3module
1条回答
网友
1楼 · 发布于 2024-10-01 07:10:58
% python3  version
Python 3.7.2
% pip3 install cvxopt 
Collecting cvxopt
  Using cached cvxopt-1.2.6-cp38-cp38-macosx_10_9_x86_64.whl (3.1 MB)

默认的python3是3.7,但pip3在Python 3.8下运行。选择要使用的Python并使用该Python

要么跑

python3.7 -m pip install cvxopt

然后使用python3.7运行脚本

或者以同样的方式使用python3.8

相关问题 更多 >