$ docker-compose up
Creating network "app_default" with the default driver
ERROR: b'failed to parse pool request for address space "LocalDefault" pool "" subpool "": could not find an available predefined network'
Run Code Online (Sandbox Code Playgroud)
这个错误是什么意思,我该如何解决?
附加背景:
$ docker-compose version
docker-compose version 1.7.1, build 6c29830
docker-py version: 1.8.1
CPython version: 3.5.1
OpenSSL version: OpenSSL 1.0.2h 3 May 2016
$ docker version
Client:
Version: 1.10.3
API version: 1.22
Go version: go1.5.3
Git commit: 20f81dd
Built: Thu Mar 10 21:49:11 2016
OS/Arch: darwin/amd64
Server:
Version: 1.11.1 …Run Code Online (Sandbox Code Playgroud) 我一直在尝试获取此处的xml数据:http: //www.thetvdb.com/api/D1BD82E2AE599ADD/mirrors.xml
您会注意到在Web浏览器中可以轻松读取xml数据.但是,当我尝试使用urllib2加载它时,会出现以下问题.(根据http://www.doughellmann.com/PyMOTW/urllib2/上的教程):
import urllib2
response = urllib2.urlopen('http://www.thetvdb.com/api/D1BD82E2AE599ADD/mirrors.xml')
print response.read()
Run Code Online (Sandbox Code Playgroud)
输出:
'<?xml version="1.0" encoding="UTF-8" ?>\n<Mirrors>\n <Mirror>\n <id>1</id>\n <mirrorpath>http://thetvdb.com</mirrorpath>\n <typemask>7</typemask>\n </Mirror>\n</Mirrors>\n'
Run Code Online (Sandbox Code Playgroud)
我已尝试过其他网站(例如:python.org),它似乎有效.这个问题似乎是独立于库的(我对urllib,httplib,httplib2等有同样的问题),问题似乎是我想要获取的网站特有的.
是什么赋予了?
编辑:好吧,好像我对"应该"看到的东西感到困惑.出于好奇,有人知道"脚本"部分是什么吗?我正在使用谷歌浏览器(稳定版)查看该页面.
我正试着用Go语言包围我用这个简单的例子击中了我的第一个绊脚石:
package main
import (
"encoding/json"
"fmt"
)
type MyStructure struct {
Integer int `json:"integer"`
Label string `json:"label"`
}
func main() {
ms := &MyStructure{9001, "over9000"}
msjson, _ := json.Marshal(ms)
fmt.Println(msjson) // expect: {"integer": 9001, "label": "over9000"}
}
Run Code Online (Sandbox Code Playgroud)
我的输出如下: [123 34 105 110 116 101 103 101 114 34 58 57 48 48 49 44 34 108 97 98 101 108 34 58 34 111 118 101 114 57 48 48 48 34 125]
我显然错过了一些明显的东西; 有人可以指点我正确的方向吗?
我最近安装了 pyenv,以便在每个项目的基础上在几个竞争的 python 解释器之间切换。因此,将入口点python setup.py develop放置在. 但是,从命令行调用这些脚本之一(例如:) 会导致错误:找不到该命令。console_script~/.pyenv/versions/3.4.3/bin$ my_entry_point_script
我该如何解决这个问题?$PATH这是、$PTHONPATH、 其他问题吗?作为参考,我的 shell (fish)status --is-interactive; and . (pyenv init -lpsub)在启动时执行。
编辑: 正确的解决方案将保持不同版本的 python 之间的清晰分离。
我正在尝试构建一个gliderlabs/alpine:latest仅包含pyenv及其依赖关系的docker镜像.我希望这个容器能够通过pyenv安装和执行任意解释器.
我从以下Dockerfile开始:
FROM gliderlabs/alpine:latest
RUN apk-install curl \
ca-certificates \
bash \
git \
openssl-dev \
readline-dev \
bzip2-dev \
sqlite-dev \
build-base
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer -o /pyenv-installer
RUN touch /root/.bashrc && \
/bin/ln -s /root/.bashrc /root/.bash_profile && \
/bin/bash /pyenv-installer && \
rm /pyenv-installer && \
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile && \
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile && \
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
ENV HOME /root
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH …Run Code Online (Sandbox Code Playgroud) 给定两个包含x和y坐标的2D numpy数组,如何在另一个具有相同尺寸的数组中找到相同的对?
例如,我有这些数组:
array([[ 2, 1, 3, 4],
[ 4, 3, 5, 10]])
Run Code Online (Sandbox Code Playgroud)
和
array([[ 0, 2, 3, 4],
[ 3, 4, 11, 10]])
Run Code Online (Sandbox Code Playgroud)
我希望找到这些对(2, 4)并且(4, 10)将被检测为存在于两个阵列中.
首先十分感谢!
我写了这个快速功能来熟悉boost::program_options.请注意,这po是一个名称空间别名,定义如下: namespace po = boost::program_options.
int application(po::variables_map* vm)
{
std::cout << vm << std::endl;
std::cout << *vm["infile"].value();
// also tried: std::cout << *vm["infile"]
return SUCCESS;
} //application
Run Code Online (Sandbox Code Playgroud)
当我在函数体中注释掉第二行时,应用程序成功编译并打印了地址vm.但是,当我尝试使用此处出现的函数进行编译时,我得到以下编译器侮辱:
invalid types ‘boost::program_options::variables_map*[const char [7]]’ for array subscript
Run Code Online (Sandbox Code Playgroud)
我应该注意用std::cout << vm->count("infile")返回 替换第二行1.
我做错了什么?我是在滥用助推器构造还是在(de)引用中混淆了vm?
更新
根据建议我通过引用传递以避免运算符优先级问题,我重写了我的函数:
int application(po::variables_map& vm)
{
std::cout << &vm << std::endl;
std::cout << vm["infile"].value();
return SUCCESS;
} //application
Run Code Online (Sandbox Code Playgroud)
我现在得到一个不同的错误:
no match for ‘operator<<’ (operand types are …Run Code Online (Sandbox Code Playgroud) 给定一个3列数据帧,df:
a b c
0 NaN a True
1 1 b True
2 2 c False
3 3 NaN False
4 4 e True
[5 rows x 3 columns]
Run Code Online (Sandbox Code Playgroud)
我想放置NaN在列c对于其中每行NaN中的任何其他colunn存在.我目前的做法如下:
for col in df:
df['c'][pd.np.isnan(df[col])] = pd.np.nan
Run Code Online (Sandbox Code Playgroud)
我强烈怀疑有一种方法可以通过逻辑索引来实现,而不是像我目前所做的那样迭代列.
怎么可以这样做?
谢谢!
我正在使用gorm ORM在 go 中编写一个小型、简单的网络应用程序。
由于数据库可能会独立于 Web 应用程序而失败,因此我希望能够识别与这种情况相对应的错误,以便我可以在不重新启动 Web 应用程序的情况下重新连接到我的数据库。
激励示例:
考虑以下代码:
var mrs MyRowStruct
db := myDB.Model(MyRowStruct{}).Where("column_name = ?", value).First(&mrs)
return &mrs, db.Error
Run Code Online (Sandbox Code Playgroud)
在这种情况下,db.Error != nil我如何以编程方式确定错误是否源于数据库连接问题?
从我的阅读中,我明白这gorm.DB 并不代表一个连接,所以我什至不必担心gorm.Open如果数据库连接失败则重新连接或重新发出调用?
Go 中是否有处理数据库故障的通用模式?
下面是一个启动外部进程的函数,将正则表达式与进程的标准输出进行匹配,并返回匹配的内容.
func (c *Colony) startCircuit(peer *string) (string, error) {
var (
err error
cmd *exec.Cmd
anchorChan chan string
)
// ... (omitted for readability)
// get the anchor from standard output
go func() {
defer out.Close()
anchorChan = make(chan string)
for scanner := bufio.NewScanner(out); scanner.Scan(); {
line := scanner.Text()
if anchor := reRootAnchor.FindString(line); anchor != "" {
log.Println("Started circuit server with anchor:", anchor)
anchorChan <- anchor
break
}
}
}()
anchor := <-anchorChan
return anchor, err
}
Run Code Online (Sandbox Code Playgroud)
运行该函数时,我获得以下输出,表明确实找到了匹配并且(可能)被推入anchorChan: …