ermutuxia

2021-04-14   阅读量: 59

Python

安装fancyimpute库所踩的一些坑

pip install --user fancyimpute -i https://pypi.douban.com/simple




D:\ProgramData\Anaconda3;D:\ProgramData\Anaconda3\Library\mingw-w64\bin;D:\ProgramData\Anaconda3\Library\usr\bin;D:\ProgramData\Anaconda3\Library\bin;D:\ProgramData\Anaconda3\Scripts;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Graphviz\bin;C:\Program Files\MySQL\MySQL Server 8.0\bin;D:\软件\swigwin-4.0.2\swigwin-4.0.2;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;D:\软件\ffmpeg-4.3.2-2021-02-27-essentials_build\ffmpeg-4.3.2-2021-02-27-essentials_build\bin;C:\Users\Administrator\AppDa

ta\Roaming\Python\Python38\Scripts;C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages



WARNING: The scripts estimator_ckpt_converter.exe, import_pb_to_tensorboard.ex

e, saved_model_cli.exe, tensorboard.exe, tf_upgrade_v2.exe, tflite_convert.exe,

toco.exe and toco_from_protos.exe are installed in 'C:\Users\Administrator\AppDa

ta\Roaming\Python\Python38\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warn

ing, use --no-warn-script-location.



pip install --target=D:/ProgramData/Anaconda3/Lib/site-packages fancyimpute -i https://pypi.douban.com/simple

D:\ProgramData\Anaconda3\Lib\site-packages



pip install --target=D:/ProgramData/Anaconda3/Lib/site-packages --use-feature=2020-resolver pyqtwebengine==5.12 -i https://pypi.douban.com/simple

pip install --target=D:/ProgramData/Anaconda3/Lib/site-packages --use-feature=2020-resolver --upgrade pyqt5==5.12 -i https://pypi.douban.com/simple




#升级spyder

pip install --target=D:\ProgramData\Anaconda3\Lib\site-packages --use-feature=2020-resolver --upgrade spyder==4.2.4 -i https://pypi.douban.com/simple


ERROR: tensorflow 2.4.1 requires numpy~=1.19.2, but you'll have numpy 1.20.2 whi

ch is incompatible.


然后看下我们当前电脑中numpy的版本

C:\Users\Administrator>conda list numpy

# packages in environment at D:\ProgramData\Anaconda3:

#

# Name Version Build Channel

numpy 1.20.2 pypi_0 pypi

numpy-base 1.19.2 py38ha3acd2a_0

numpydoc 1.1.0 pyhd3eb1b0_1


然后看下我们当前电脑中tensorflow的版本

C:\Users\Administrator>conda list tensorflow

# packages in environment at D:\ProgramData\Anaconda3:

#

# Name Version Build Channel

tensorflow 2.4.1 pypi_0 pypi

tensorflow-estimator 2.4.0 pypi_0 pypi





#结果提示当前的tensorflow版本需要一个比较低版本的numpy

#这时我们要么升级tensorflow,要么降级numpy

#我们先升级tensorflow试一试


#升级 tensorflow

#先看下tensorflow都有哪些版本

pip install tensorflow==*

#看下我们电脑上装的tensorflow是哪个版本

conda list tensorflow

#选择一个tensorflow版本进行安装

pip install --target=D:\ProgramData\Anaconda3\Lib\site-packages --use-feature=2020-resolver --upgrade tensorflow==2.5.0rc1 -i https://pypi.douban.com/simple


结果提示如下错误,有可能是因为豆瓣镜像上没有这个版本。

ERROR: Could not find a version that satisfies the requirement tensorflow==2.5.0


ERROR: No matching distribution found for tensorflow==2.5.0


接下来我们降级numpy


pip install --target=D:\ProgramData\Anaconda3\Lib\site-packages --use-feature=2020-resolver --upgrade numpy==1.19.2 -i https://pypi.douban.com/simple

发现可以安装成功,看下现在电脑中的numpy变成多少了

C:\Users\Administrator>conda list numpy

# packages in environment at D:\ProgramData\Anaconda3:

#

# Name Version Build Channel

numpy 1.20.2 pypi_0 pypi

numpy-base 1.19.2 py38ha3acd2a_0

numpydoc 1.1.0 pyhd3eb1b0_1



为什么那个numpy还是1.20.2呢?如何处理


我们先卸载numpy,然后再安装numpy


在anaconda prompt里面执行下面的代码

pip uninstall numpy

pip install --use-feature=2020-resolver --upgrade numpy==1.19.2 -i https://pypi.douban.com/simple


发现没有错误提示,再看下numpy的版本

C:\Users\Administrator>conda list numpy

# packages in environment at D:\ProgramData\Anaconda3:

#

# Name Version Build Channel

numpy 1.19.5 pypi_0 pypi

numpy-base 1.19.2 py38ha3acd2a_0

numpydoc 1.1.0 pyhd3eb1b0_1




#接下来再安装指定版本的spyder

#根据前面的经验,我们先卸载已经安装的spyder

启动anaconda prompt 然后输入pip uninstall spyder

然后再输入 pip install spyder --use-feature=2020-resolver --upgrade spyder==4.2.4 -i https://pypi.douban.com/simple


然后也没有提示出错,spyder4.2.4 安装成功

然后安装fancyimpute

如果以前安装过fancyimpute,却没有安装成功,则需要先卸载一下

pip uninstall fancyimpute

然后再安装

pip install --use-feature=2020-resolver --upgrade fancyimpute -i https://pypi.douban.com/simple

没有错误提示,但是也没有说安装成功。


然后用import命令导入,却出现错误提示


---------------------------------------------------------------------------

RuntimeError Traceback (most recent call last)

RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd


---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

<ipython-input-1-3f82472c4160> in <module>

----> 1 import fancyimpute


D:\ProgramData\Anaconda3\lib\site-packages\fancyimpute\__init__.py in <module>

2

3 from .solver import Solver

----> 4 from .nuclear_norm_minimization import NuclearNormMinimization

5 from .matrix_factorization import MatrixFactorization

6 from .iterative_svd import IterativeSVD


D:\ProgramData\Anaconda3\lib\site-packages\fancyimpute\nuclear_norm_minimization.py in <module>

11 # limitations under the License.

12

---> 13 import cvxpy


应该是numpy版本太低,那我们还需要将numpy 版本走回到新版本,汗

先关闭你打开的spyder 还有jupyter notebook(后台),否则执行下面的代码会有错误提示

先卸载numpy 然后再安装numpy

启动anaconda prompt

pip uninstall numpy

卸载过程没有出现错误提示。但是为什么卸载完成之后用conda list命令看的时候还是有numpy呢?

这应该是没有卸载干净,我们还需要手动将site-packages下面和numpy直接相关的三个文件夹删掉


numpy numpydoc numpydoc-1.1.0.dist-info


删掉之后再执行conda list还是能看到numpy库 pip list 看不到numpy库

打开一个jupyter book,然后在里面输入import numpy库,已经提示这个库不存在。


然后关闭jupyter notebook执行

pip install --use-feature=2020-resolver --upgrade numpy -i https://pypi.douban.com/simple


提示错误

Installing collected packages: numpy

ERROR: tensorflow 2.4.1 requires numpy~=1.19.2, but you'll have numpy 1.20.2 whi

ch is incompatible.

Successfully installed numpy-1.20.2


但是import numpy库已经可以正常导入了。site-packages文件夹下面多了两个文件夹 numpy和 numpy-1.20.2.dist-info


site-packages文件夹下面有两个和tensorflow相关的文件。分别是tensorflow和tensorflow-2.4.1.dist-info



我们换成高版本的tensorflow试试

先卸载pip uninstall tensorflow没有错误提示 然后删除site-packages文件夹下面的tensorflow和tensorflow-2.4.1.dist-info两个文件夹

执行pip list看不到tensorflow了

执行conda list 也看不到tensorflow了 numpy显示1.20.2的版本

然后我们安装tensorflow

pip install --use-feature=2020-resolver --upgrade tensorflow -i https://pypi.douban.com/simple

发现tensorflow的安装过程中为了能让tensorflow正确安装卸载了电脑上已经装好的numpy 1.20.2,重新安装了numpy-1.19.5,具体过程如下

Installing collected packages: numpy, tensorflow

Attempting uninstall: numpy

Found existing installation: numpy 1.20.2

Uninstalling numpy-1.20.2:

Successfully uninstalled numpy-1.20.2

Successfully installed numpy-1.19.5 tensorflow-2.4.1

没有错误提示成功安装了tensorflow-2.4.1

这时发现site-packages文件夹下面以前的numpy-1.20.2.dist-info变成了numpy-1.19.5.dist-info

也就是numpy-1.19.5 tensorflow-2.4.1这两个是相匹配的。




接下来重整思路看下如何安装pip install fancyimpute









0.0000 0 0 关注作者 收藏

评论(0)


暂无数据

推荐课程