+-
“pip install openopt”相关错误的解决方法

想用python进行CGE模型的使用,我在pip install --user openopt时遇到了以下问题:

问题一

  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for setproctitle
Failed to build setproctitle
ERROR: Could not build wheels for setproctitle which use PEP 517 and cannot be installed directly

image.png
提示错误:error: Microsoft Visual C++ 14.0 or greater is required.

解决问题一

这个问题的解决请看我的另一篇文章:“Microsoft visual c++ 14.0 is required”错误的解决方法。

问题二

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
ERROR: Failed building wheel for setproctitle

image.png
提示错误:error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
这是啥问题姑且不论,但是后面提示错误ERROR: Failed building wheel for setproctitle

解决问题二

可以在这里找到预编译的wheels:https://www.lfd.uci.edu/~gohl...
选择合适的版本下载就可以了。

查看自己python版本号的办法是在cmd输入pythonimage.png

比如我是64位的python3.6我就下这个:image.png

如果不下载正确的版本就会报错:ERROR: setproctitle-1.1.10-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform

下载好whl文件之后需要复制该文件的路径(比如我的路径在C:\Users\MI\Downloads\setproctitle-1.1.10-cp36-cp36m-win_amd64.whl)。
然后在命令行输入以下命令:

pip install "所复制的路径"

如我输入以下命令:

pip install "C:\Users\MI\Downloads\setproctitle-1.1.10-cp36-cp36m-win_amd64.whl"

可以看到setproctitle安装成功:
image.png

接下来再回到openopt

pip install --user openopt

可以看到openopt安装成功:
image.png

问题三

运行代码中报错:

oologfcn.OpenOptException: For the problem you should have DerApproximator installed, see http://openopt.org/DerApproximator

不巧openopt的官网正在维护QAQ:
image.png

解决问题三(坑)

无论是找了网上的DerApproximator还是什么都不能解决这一问题……
无奈之下,用python2重新跑程序……
遇到这个问题的时候,使用pip2.7 install DerApproximator终于解决了…………

彩蛋:CGE模型源码

主程序:

# 占坑

其他程序:

# 占坑

参考

How to install setproctitle on windows?
python-cge