python -m visdom.server
然后就一直卡在如下画面
启动卡住
解决办法
下载下面的压缩包,解压(PS:如果你看完全文,你会跳转到最后下载那个版本而不是这个)
visdom 0.1.8.5版本的
https://wwx.lanzoux.com/iUtRBknwimf 密码:ergy
找visdom库的位置
方法一:在python里运行
import os
import visdom
print(os.path.dirname(visdom.__file__))
即可得到
方法二:find命令
find / -name "visdom"
例如我的:/opt/conda/lib/python3.8/site-packages/visdom
将刚刚解压后的文件夹复制到那即可
cp -r ./static /opt/conda/lib/python3.8/site-packages/visdom
注意:以上是针对0.1.8.5的visdom,如果是0.1.8.5那么就可以了
版本高于0.1.8.5的visdom
import visdom
print(os.path.dirname(visdom.__version__))
查看visdom版本
比如:0.1.8.9
则再运行一句:
echo '0.1.8.9' > /opt/conda/lib/python3.8/site-packages/visdom/static/version.built
测试一下:
python -m visdom.server
成功启动visdom
写在最后,不深究的话可以不用看
其实在启动vidom会运行一下/opt/conda/lib/python3.8/site-packages/visdom/server.py里最下面有个调用download_scripts()
所有下载都在download_scripts()里,上面的过程也是基于这个函数写的
# function that downloads and installs javascript, css, and font dependencies:
def download_scripts(proxies=None, install_dir=None):
import visdom
print("Checking for scripts.")
# location in which to download stuff:
if install_dir is None:
install_dir = os.path.dirname(visdom.__file__)
# all files that need to be downloaded:
b = 'https://unpkg.com/'
bb = '%sbootstrap@3.3.7/dist/' % b
ext_files = {
# - js
'%sjquery@3.1.1/dist/jquery.min.js' % b: 'jquery.min.js',
'%sbootstrap@3.3.7/dist/js/bootstrap.min.js' % b: 'bootstrap.min.js',
'%sreact@16.2.0/umd/react.production.min.js' % b: 'react-react.min.js',
'%sreact-dom@16.2.0/umd/react-dom.production.min.js' % b:
'react-dom.min.js',
'%sreact-modal@3.1.10/dist/react-modal.min.js' % b:
'react-modal.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_SVG': # noqa
'mathjax-MathJax.js',
# here is another url in case the cdn breaks down again.
# https://raw.githubusercontent.com/plotly/plotly.js/master/dist/plotly.min.js
'https://cdn.plot.ly/plotly-latest.min.js': 'plotly-plotly.min.js',
# Stanford Javascript Crypto Library for Password Hashing
'%ssjcl@1.0.7/sjcl.js' % b: 'sjcl.js',
# - css
'%sreact-resizable@1.4.6/css/styles.css' % b:
'react-resizable-styles.css',
'%sreact-grid-layout@0.16.3/css/styles.css' % b:
'react-grid-layout-styles.css',
'%scss/bootstrap.min.css' % bb: 'bootstrap.min.css',
# - fonts
'%sclassnames@2.2.5' % b: 'classnames',
'%slayout-bin-packer@1.4.0/dist/layout-bin-packer.js' % b:
'layout_bin_packer.js',
'%sfonts/glyphicons-halflings-regular.eot' % bb:
'glyphicons-halflings-regular.eot',
'%sfonts/glyphicons-halflings-regular.woff2' % bb:
'glyphicons-halflings-regular.woff2',
'%sfonts/glyphicons-halflings-regular.woff' % bb:
'glyphicons-halflings-regular.woff',
'%sfonts/glyphicons-halflings-regular.ttf' % bb:
'glyphicons-halflings-regular.ttf',
'%sfonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular' % bb: # noqa
'glyphicons-halflings-regular.svg#glyphicons_halflingsregular',
}
# make sure all relevant folders exist:
dir_list = [
'%s' % install_dir,
'%s/static' % install_dir,
'%s/static/js' % install_dir,
'%s/static/css' % install_dir,
'%s/static/fonts' % install_dir,
]
for directory in dir_list:
if not os.path.exists(directory):
os.makedirs(directory)
# set up proxy handler:
from six.moves.urllib import request
from six.moves.urllib.error import HTTPError, URLError
handler = request.ProxyHandler(proxies) if proxies is not None \
else request.BaseHandler()
opener = request.build_opener(handler)
request.install_opener(opener)
built_path = os.path.join(here, 'static/version.built')
is_built = visdom.__version__ == 'no_version_file'
if os.path.exists(built_path):
with open(built_path, 'r') as build_file:
build_version = build_file.read().strip()
if build_version == visdom.__version__:
is_built = True
else:
os.remove(built_path)
if not is_built:
print('Downloading scripts, this may take a little while')
# download files one-by-one:
for (key, val) in ext_files.items():
# set subdirectory:
if val.endswith('.js'):
sub_dir = 'js'
elif val.endswith('.css'):
sub_dir = 'css'
else:
sub_dir = 'fonts'
# download file:
filename = '%s/static/%s/%s' % (install_dir, sub_dir, val)
if not os.path.exists(filename) or not is_built:
req = request.Request(key,
headers={'User-Agent': 'Chrome/30.0.0.0'})
try:
data = opener.open(req).read()
with open(filename, 'wb') as fwrite:
fwrite.write(data)
except HTTPError as exc:
logging.error('Error {} while downloading {}'.format(
exc.code, key))
except URLError as exc:
logging.error('Error {} while downloading {}'.format(
exc.reason, key))
if not is_built:
with open(built_path, 'w+') as build_file:
build_file.write(visdom.__version__)
它下载也就是下载static文件夹
对于为什么要
echo '0.1.8.9' > /opt/conda/lib/python3.8/site-packages/visdom/static/version.built
是因为download_scripts()里面这一小段
built_path = os.path.join(here, 'static/version.built')
is_built = visdom.__version__ == 'no_version_file'
if os.path.exists(built_path):
with open(built_path, 'r') as build_file:
build_version = build_file.read().strip()
if build_version == visdom.__version__:
is_built = True
else:
os.remove(built_path)
if not is_built:
print('Downloading scripts, this may take a little while')
也就是版本号不一致它还是会下载,但是我们就是因为下载不了才卡住的,所以直接改版本号
当然,这样做也是有缺点的,那就是最新版本下载的东西和我们文件夹里的不一样了,那就GG了
所以直接改版本号不是一个好的方式。
我这在提供一个0.1.8.9版本的
下载:https://wwx.lanzoux.com/iNSrhknzr1g 密码:4rkz
如果版本再有更新的话,那就先找能够启动最新版本的电脑拷贝一下static文件夹吧
网友评论