1.pip 错误之改正(仅供参考,看完再实践)
在github上下载了keras-GAN,使用下列命令下载的时候
$ git clone https://github.com/eriklindernoren/Keras-GAN
$ cd Keras-GAN/
$ sudo pip3 install -r requirements.txt
出现报错:
...............................................
Complete output from command python setup.py egg_info:
Beginning with Matplotlib 3.1, Python 3.6 or above is required.
This may be due to an out of date pip.
Make sure you have pip >= 9.0.1.
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-medlthyy/matplotlib/
坑(1):提示需要升级pip,按照命令pip install --upgrade pip报错:ImportError: No module named _internal
坑(2):那就升级matplotlib:pip install --upgrade matplotlib,报错:ImportError: No module named _internal
陷入僵局.......
解决办法:命令:sudo -H python -m pip install --upgrade pip 成功升级pip。
那就继续安装:pip3 install -r requirements.txt.依然报错:同最开始一样。
最后解决办法:
(1)卸载pip
卸载:
sudo apt remove python-pip
安装依赖:
sudo apt-get install python-setuptools python-dev build-essential
(2)安装:
sudo easy_install pip
sudo apt-get install python3-pip
sudo python -m pip install --upgrade --force pip
sudo pip install -i https://pypi.douban.com/simple setuptools==33.1.1
最后:此时pip安装完成,可以继续下载keras-gan的文件:
sudo pip3 install -r requirements.txt
安装成功
参考:
pip 安装包时报错 /usr/bin/pip: No such file or directory
2.运行手写数据集实例
$ cd acgan/
$ python3 acgan.py
emmmmm,报错:no moudle named ‘keras’
然后我才知道,要先安装tf框架,再在tf框架上面安装keras,好了下面安装:主要是借鉴了这位优秀的手法,比较全面:使用anaconda安装tensorflow (windows10环境)
命令(命令说明见上链接):
已经安装Anaconda2,3也可以
conda --version
conda info --envs
conda search --full -name tensorflow
conda info tensorflow
conda create --name tfenv python=3.6
source activate tfenv
pip install --upgrade --ignore-installed tensorflow
然后安装:
pip install keras
pip install matplotlib
运行结果:
3.cyclegan训练
命令:
$ cd cyclegan/
$ bash download_dataset.sh apple2orange
$ python3 cyclegan.py
最后一句命令报错及其解决:
(1):No module named 'keras_contrib'
解决:pip install git+https://www.github.com/keras-team/keras-contrib.git
(2):
module 'scipy' has no attribute 'misc'
解决:降级scipy的版本
pip install scipy==1.1.0
或者 import scipy.misc #将此模块导入
(3):AttributeError: module 'scipy.misc' has no attribute 'imread'
解决:完美解决AttributeError: module 'scipy.misc' has no attribute 'imread'报错问题
此处我用安装pillow解决:pip install Pillow
未必可以解决,我总结了一下,貌似是高版本的tensorlow已经弃用该模块,tensorflow2.0里面是没有这个模块的;参考我的版本配置python3.6+tensorflow-gpu1.15.0+keras2.2.4