我一直在R包,它通过一个简单的服务器脚本和套接字连接使用Python接口。我可以测试我自己的机器就好了,但我想,以测试它在特拉维斯建设,以及(我不想去通过建立一个Linux VM的努力)。要做到这一点,我需要一个Python安装,我可以传递的路径,在我的[R封装测试,使用的端口号。
我见过this answer提示安装多个Python的构建是可能的,但我不知道如何处理
是否有可能做我想做的特拉维斯什么?我想与特拉维斯做到这一点?
编辑这里是我的特拉维斯配置:
language: r
r:
- release
- devel
cache: packages
sudo: false
matrix:
include:
- python:2.7
- python:3.6
# Be strict when checking our package
warnings_are_errors: true
# System dependencies for HTTP calling
r_binary_packages:
- jsonlite
- R6
这里是我的[R包的例子:
pypath = Sys.which('python')
if(nchar(pypath) > 0) {
py = PythonEnv$new(port = 6011, path = pypath)
py$start
py$running
py$set(a = 5)
py$get('a')
py$stop
} else {
message("No Python environment available")
}
我的例子肯定是找到一个Python的路径,但失败,出现错误
在警告SocketConnection处(口=自我$端口,开放= “R +”,阻断= TRUE,:本地主机:6011无法打开
SocketConnection处错误(端口=自我$端口,开放= “R +”,阻断= TRUE,: 无法打开连接
我用另一个端口进行测试这一点,并会出现同样的错误。
编辑2
我也与主机127.0.0.1
和0.0.0.0
但没有骰子尝试过。据特拉维斯文档,这应该工作...也许是一个问题的R容器?
这里是一个travis.yml我用我pyrle包。它只是安装[R usinq Ubuntu的软件包管理器:
language: python
python:
- "3.6"
install:
- pip install cython pytest hypothesis
- sudo apt-get install -y r-base
- echo 'source("https://bioconductor.org/biocLite.R"); biocLite("S4Vectors"); biocLite("GenomicRanges")' > install.R
- python setup.py install
script:
- py.test tests/
另一种方式是通过畅达来安装R。下面是从pyranges包的示例:
# Stolen from http://conda.pydata.org/docs/travis.html
language: python
python:
# We don't actually use the Travis Python, but this keeps it organized.
- "3.6"
install:
- sudo apt-get update
# We do this conditionally because it saves us some downloading if the
# version is the same.
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda config --add channels bioconda
- conda config --add channels r
# Useful for debugging any issues with conda
- conda info -a
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy pandas pytest pytest-cov cython tabulate hypothesis bedtools # ray
- source activate test-environment
- python setup.py install # will install ncls
- python --version
- python -c 'import pandas as pd; print(pd.__version__)'
- ls tests
script: py.test -v tests # verbose to see that tests run and so that travis does not time out on hypothesis tests
你的问题标题和问题,身体有很大的不同。
同样以The Unfun Cat's answer它采用特拉维斯安装Python和安装R 2与容易,你可以用特拉维斯的R和用apt安装python:
language: r
install:
- sudo apt-get install -y python2.7 python3.6
需要注意的是特拉维斯也has an apt addon使你.yaml一点清洁剂(但可以说的可移植性)。
language: r
addons:
apt:
packages:
- python2.7
- python3.6
安装应该可以访问不同的Python版本Sys.which
为python2.7
和python3.6
,而不是仅仅“蟒蛇”。 which python
将返回安装,否则最后的版本最后安装的python2*
。
有许多的原因,您可能无法建立连接。一个常见的原因是该端口已在使用。端口6011有时会被X窗口系统(ref),所以有可能的特拉维斯的服务,一个正在使用它。
使用this reference on how to check for used ports你可以尝试添加类似
sudo lsof -i -P -n | grep LISTEN | grep 6011
您travis.yaml
这样你就可以在日志中查看是否使用的端口。您也可以尝试在你的脚本不同的未使用的端口号。
我确实发现this github comment引用有R特别类似的问题;你或许可以找到更多的在那里。