gpt4 book ai didi

python - 使用 conda 更新包时出错

转载 作者:行者123 更新时间:2023-12-04 19:15:11 25 4
gpt4 key购买 nike

我在 AWS EC2 上启动了一个使用 ubuntu 作为 AMI 的实例。

然后我运行了一个脚本来安装 jupyter notebook 并能够使用 IP 地址和特定端口访问它。
我写的代码是这样的:

sudo apt-get install git

git clone https://gist.github.com/rashmibanthia/5a1e4d7e313d6832f2ff nb

. nb/jupyter_notebook_ec2.sh

cd;mkdir notebook;cd notebook

tmux new -s nb

jupyter notebook --certfile=~/certs/mycert.pem --keyfile ~/certs/mycert.key

现在我在笔记本上。我的问题来了。当我尝试导入一些包和类时,出现错误。例如这一行:
from sklearn.gaussian_process import GaussianProcessRegressor

我明白了:

ImportError Traceback (most recent call last) in () ----> 1 from sklearn.gaussian_process import GaussianProcessRegressor

ImportError: cannot import name 'GaussianProcessRegressor'



所以我尝试用 conda update scikit-learn 更新 scikit learn 包,但我有另一个错误:

Fetching package metadata ...An unexpected error has occurred. Please consider posting the following information to the conda GitHub issue tracker at:

https://github.com/conda/conda/issues


当前 conda 安装:
           platform : linux-64
conda version : 4.2.13
conda is private : False
conda-env version : 4.2.13
conda-build version : 1.18.2
python version : 3.5.2.final.0
requests version : 2.12.1
root environment : /home/ubuntu/anaconda3 (writable)
default environment : /home/ubuntu/anaconda3
envs directories : /home/ubuntu/anaconda3/envs
package cache : /home/ubuntu/anaconda3/pkgs
channel URLs : https://repo.continuum.io/pkgs/free/linux-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/pro/linux-64
https://repo.continuum.io/pkgs/pro/noarch
config file : None
offline mode : False
$ /home/ubuntu/anaconda3/bin/conda update scikit-learn

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/exceptions.py", line 479, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/cli/main.py", line 145, in _main
exit_code = args.func(args, p)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/cli/main_update.py", line 65, in execute
install(args, parser, 'update')
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/cli/install.py", line 238, in install
prefix=prefix)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/api.py", line 24, in get_index
index = fetch_index(channel_urls, use_cache=use_cache, unknown=unknown)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/fetch.py", line 300, in fetch_index
repodatas = [(u, f.result()) for u, f in zip(urls, futures)]
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/fetch.py", line 300, in <listcomp>
repodatas = [(u, f.result()) for u, f in zip(urls, futures)]
File "/home/ubuntu/anaconda3/lib/python3.5/concurrent/futures/_base.py", line 405, in result
return self.__get_result()
File "/home/ubuntu/anaconda3/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
raise self._exception
File "/home/ubuntu/anaconda3/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/fetch.py", line 75, in func
res = f(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/conda/fetch.py", line 117, in fetch_repodata
timeout=(6.1, 60))
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 350, in _make_request
self._validate_conn(conn)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 835, in _validate_conn
conn.connect()
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 330, in connect
cert = self.sock.getpeercert()
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 324, in getpeercert
'subjectAltName': get_subj_alt_name(x509)
File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 171, in get_subj_alt_name
ext = cert.extensions.get_extension_for_class(
AttributeError: 'Extensions' object has no attribute 'get_extension_for_class'

最佳答案

正如 kalefranz 在这里评论'https://github.com/conda/conda/issues/3898 ' 这可能是因为 pyopenssl 和密码学不同步,这应该可以解决它:

CONDA_SSL_VERIFY=false conda 更新 pyopenssl

在 windows 中设置 ssl_verify 可以使用以下命令:

conda config --set ssl_verify False

正如 Problems with updating anaconda and installing new packages 中所说

关于python - 使用 conda 更新包时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40877501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com