我先安装了anaconda2,再在他的envs目录下安装anaconda3,想要python2,3共存
(E:\ANACONDA) C:\Users\Administrator>E:\ANACONDA\envs\PY3\Scripts\pip install tensorflow
上面这段安装tensorflow成功
我之前有在python2的环境下安装keras在python2环境下的Jupyter可以import进去
(E:\ANACONDA) C:\Users\Administrator>E:\ANACONDA\envs\PY3\Scripts\pip install keras
Collecting keras
再使用上面这个命令安装keras,报错
Collecting keras
Exception:
Traceback (most recent call last):
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "E:\ANACONDA\envs\PY3\lib\site-packages\pip\index.py", line 731, in __init__
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
网上有一个方法如下,但是好像因为我的python2已经安装了keras,它拒绝再安装了
(E:\ANACONDA) C:\Users\Administrator>E:\ANACONDA\envs\PY3\Scripts\conda install pip
Fetching package metadata .............
Solving package specifications: .
InstallError: Error: one or more of the packages already installed depend on 'conda'
and should only be installed in the root environment: conda conda-env
These packages need to be removed before conda can proceed.
好吧,问题还是要自己先研究一下
第一步,用anaconda prompt在anaconda\envs目录下创建python35,再在里面安装tensorflow和keras
第二步,还是anaconda prompt里面
activate python35
,python -m ipykernel install --user
,就是在anaconda2环境下的jupyter里面创建python3的核我之前有安装好,在spyder上导入keras提示我CPU运算量不足的,不过现在在jupyter里面没有再提醒了