看板 Python 關於我們 聯絡資訊
大家好 我寫這題 https://imgur.com/NjXQp5T import cvxpy和qcqp時出現了下面error ImportError: cannot import name 'logsumexp' from 'scipy.misc' (C:\Users\ASUS\anaconda3\lib\site-packages\scipy\misc\__init__.py) 查了google看到logsumexp已經移到scipy.special 要把scipy downgrade到1.2.1版本才會在scipy.misc 所以我試著把sicpy降級 pip install scipy==1.2.1 出現了以下error ERROR: Command errored out with exit status 1: 'C:\Users\ASUS\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ASUS\\AppData\\Local\\Temp\\pip-install-vbzm367e\\scipy_be91b562048d490b8443345eddef9e64\\setup.py'"'"'; __file__='"'"'C:\\Users\\ASUS\\AppData\\Local\\Temp\\pip-install-vbzm367e\\scipy_be91b562048d490b8443345eddef9e64\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ASUS\AppData\Local\Temp\pip-record-j3bw7xdy\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\ASUS\anaconda3\Include\scipy' Check the logs for full command output. 我又試著安裝scipy 1.2.3 pip install scipy-1.2.3-cp34-cp34m-win_amd64.whl 出現了下面error ERROR: scipy-1.2.3-cp34-cp34m-win_amd64.whl is not a supported wheel on this platform. 我試著downgrade python版本 conda install python=3.4 好像也fail >< 請問到底怎麼做才能import cvxpy和qcqp啊? 或是我方向根本錯了? 有大大知道這題應該怎麼做嗎? 謝謝大家m(_ _)m -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.216.56.218 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1626584092.A.641.html
whereweare: 試看看先把 pip upgrade, 相依性問題交給系統處理 07/18 14:54
whereweare: 然後依據碰到的 Error Message 去查 Stackoverflow 07/18 14:56
whereweare: 我估狗你的第一個Error Message 有個頁面有簡單解法 07/18 15:05
whereweare: https://github.com/cvxpy/cvxpy/issues/640 07/18 15:05
whereweare: 好像你一開始的解法就把問題弄得更亂囉? 07/18 15:06
Pieteacher: 直接用 ridge regression 07/18 17:14
JamesChen: 限制式是錯的。 07/18 21:18
SHORTHAPPY: 因為是import cvxpy時發生的錯誤,沒辦法從scipy.misc 07/18 23:05
SHORTHAPPY: 改到scipy.special import啊 07/18 23:06
SHORTHAPPY: 我把題目連結改成完整的題目了,老師的要求是自己寫出 07/18 23:08
SHORTHAPPY: 最佳解的code,不能用ridge regression的package 07/18 23:12
※ 編輯: SHORTHAPPY (101.10.14.172 臺灣), 07/18/2021 23:12:46
whereweare: 我試著重現你的問題 再試著見招拆招 07/19 00:25
whereweare: conda create --name myenv python=3.6 07/19 00:28
whereweare: activate myenv 07/19 00:29
whereweare: pip install qcqp # 重點! qcqp 相依 cvxpy==0.4.x 07/19 00:30
whereweare: 各個相依套件依序裝好了... python import 測一下掛了 07/19 00:31
whereweare: 跟你開頭第一個 Error Message 一樣; pip list 看看 07/19 00:32
whereweare: scipy 版本到達 1.5.x; 你自己先前查到要版本低些 07/19 00:33
whereweare: pip uninstall scipy 然後再 pip install scipy==1.2 07/19 00:34
whereweare: 沒 error message... python import cvxpy & qcqp OK 07/19 00:34
whereweare: 剩下的就再看看你後續程式碼是否順利執行囉 07/19 00:35
SHORTHAPPY: 哇~謝謝 你的python版本是多少的啊? 07/19 00:36
whereweare: 我是2017裝的anaconda3(linux),python是3.6 07/19 00:43