各位大神,求求大家,来帮我看看吧,我已经没招了,3 天了问题都没解决,就差重装系统了!!,问题是 Python 当中 pip 安装库出现错误

2017-10-02 13:53:25 +08:00
 a1060778506

第一次用这个网站不熟悉,不能发图片,我直接贴错误代码 了

C:\Program Files\Python37\pip-9.0.1>pip install requests Collecting requests Exception: Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "C:\Program Files\Python37\lib\site-packages\pip\commands\install.py", line 324, in run requirement_set.prepare_files(finder) File "C:\Program Files\Python37\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "C:\Program Files\Python37\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file require_hashes File "C:\Program Files\Python37\lib\site-packages\pip\req\req_install.py", line 278, in populate_link self.link = finder.find_requirement(self, upgrade) File "C:\Program Files\Python37\lib\site-packages\pip\index.py", line 465, in find_requirement all_candidates = self.find_all_candidates(req.name) File "C:\Program Files\Python37\lib\site-packages\pip\index.py", line 423, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "C:\Program Files\Python37\lib\site-packages\pip\index.py", line 568, in _get_pages page = self._get_page(location) File "C:\Program Files\Python37\lib\site-packages\pip\index.py", line 683, in _get_page return HTMLPage.get_page(link, session=self.session) File "C:\Program Files\Python37\lib\site-packages\pip\index.py", line 792, in get_page "Cache-Control": "max-age=600", File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\sessions.py", line 488, in get return self.request('GET', url, **kwargs) File "C:\Program Files\Python37\lib\site-packages\pip\download.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\sessions.py", line 475, in request resp = self.send(prep, **send_kwargs) File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\sessions.py", line 596, in send r = adapter.send(request, **kwargs) File "C:\Program Files\Python37\lib\site-packages\pip_vendor\cachecontrol\adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\adapters.py", line 423, in send timeout=timeout File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\packages\urllib3\connectionpool.py", line 589, in urlopen self._prepare_proxy(conn) File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\packages\urllib3\connectionpool.py", line 797, in _prepare_proxy conn.connect() File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\packages\urllib3\connection.py", line 254, in connect conn = self._new_conn() File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\packages\urllib3\connection.py", line 142, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "C:\Program Files\Python37\lib\site-packages\pip_vendor\requests\packages\urllib3\util\connection.py", line 66, in create_connection if host.startswith('['): AttributeError: 'NoneType' object has no attribute 'startswith'

C:\Program Files\Python37\pip-9.0.1> C:\Program Files\Python37\pip-9.0.1>

这是我,安装一个最简单的库 pip install requests 没有其他的库 安装失败了,我重装过 python 和 pip 版本是 python3.7, pip 是最新版, 不要再说,是版本的问题,因为我在其他两台电脑上面用相同的安装包,都是可以正常安装的, 我重装之后,清理过注册表,能清理的方式都清理过了,也使用过,管理权安装,也更换过,安装盘符,变量路径也添加了,也使用过.whl 的方式安装,也使用过 Anaconda,但是都是不可以的,我又回到了原点,如果谁可以帮我解决,我有偿也是情愿的,感激不尽!!!

5776 次点击
所在节点    Python
32 条回复
zeroxia
2017-10-02 20:57:17 +08:00
Python 官网 3.6,安装到 C:/Python36/
打开 cmd:

python -m pip install requests
Technetiumer
2017-10-02 22:05:33 +08:00
装一个 Linux 虚拟机比在 windows 折腾各种错误、环境问题容易的多
hcnhcn012
2017-10-02 23:50:45 +08:00
直接在系统 python 环境用 pip 安装太容易出错了,而且还是在 windows,不确定因素太多了,建议:
1. 装上 linux 发行版(虚拟机或者双系统都行)
2. 在 linux 上安装上 anaconda
3. google 并下载 anaconda cheatsheet 和 conda cheatsheet 里面相关的命令都有
4. 补充: 在 anaconda 里什么都是包,包括 python 和 pip,你可以建立一个和系统 python 环境绝缘,只包括了指定 python 版本必须的包,这是一个干净的不行的 python 环境,既可以 conda install 也可以 pip,都会安装在这个环境里。这样绝对不会报错
kangkang
2017-10-03 02:02:35 +08:00
你换个安装路径试试...我看报错信息觉得可能是 program files 中间那个空格的问题...
SuT2i
2017-10-03 03:00:53 +08:00
试试 pip3 install request
lrxiao
2017-10-03 03:23:12 +08:00
https://github.com/conda/conda/issues?utf8=%E2%9C%93&q=startswith

合理的解释是 你的./condrc 写的有毛病
lrxiao
2017-10-03 03:24:52 +08:00
emm 删了 conda 了吗 那可能是 pip.conf
masha
2017-10-03 06:41:26 +08:00
还是虚拟机吧
Marsss
2017-10-03 21:30:28 +08:00
好像看到了 timeout 试试 -i 豆瓣源 注意 trust
264768502
2017-10-04 08:03:32 +08:00
github 上下源代码,运行 setup.py
或者试试官方推荐的 pipenv?
或者去这里下 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 然后安装
magicO
2017-10-06 11:52:23 +08:00
话说为啥不用 pycharm 呢。。我觉得用了 pycharm 之后。再也没担心过库管理的问题
pinsily
2017-10-06 17:12:25 +08:00
建议彻彻底底地把 python 删一遍,相关的文件、环境变量等等,然后安装 anaconda 进行管理

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/395135

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX