我在蜘蛛(Scrapy)中使用Python-Selenium,为了使用Selenium,我应该在Scrapinghub上安装xvfb。
当我使用apt-get安装xvfb时,我会收到以下错误消息:
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?在Scrapinghub上安装xvfb还有其他方法吗?
更新1
我读了这,我试着用码头,我被困在了这个阶段
shub-image init --requirements path/to/requirements.txt我读过这个
如果您在运行shub映像init时获得了这样的ImportError :您应该通过运行以下命令确保安装了最新版本的shub: $ pip安装shub --升级
但我总是有这样的错误
Traceback (most recent call last):
File "/usr/local/bin/shub-image", line 7, in <module>
from shub_image.tool import cli
File "/usr/local/lib/python2.7/dist-packages/shub_image/tool.py", line 42, in <module>
command_module = importlib.import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/shub_image/push.py", line 4, in <module>
from shub.deploy import list_targets
ImportError: cannot import name list_targets发布于 2017-06-14 10:05:45
我解决了我的问题(在剪贴中使用硒)
1-用于码头xvfb的
RUN apt-get install -qy xvfb2-用于创建坞映像我使用了这,而安装geckodriver则使用以下代码
#
# Geckodriver Dockerfile
#
FROM blueimp/basedriver
# Add the Firefox release channel of the Debian Mozilla team:
RUN echo 'deb http://mozilla.debian.net/ jessie-backports firefox-release' >> \
/etc/apt/sources.list \
&& curl -sL https://mozilla.debian.net/archive.asc | apt-key add -
# Install Firefox:
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
firefox \
# Remove obsolete files:
&& apt-get clean \
&& rm -rf \
/tmp/* \
/usr/share/doc/* \
/var/cache/* \
/var/lib/apt/lists/* \
/var/tmp/*
# Install geckodriver:
RUN export BASE_URL=https://github.com/mozilla/geckodriver/releases/download \
&& export VERSION=$(curl -sL \
https://api.github.com/repos/mozilla/geckodriver/releases/latest | \
grep tag_name | cut -d '"' -f 4) \
&& curl -sL \
$BASE_URL/$VERSION/geckodriver-$VERSION-linux64.tar.gz | tar -xz \
&& mv geckodriver /usr/local/bin/geckodriver
USER webdriver
CMD ["geckodriver", "--host", "0.0.0.0"]来自这里
发布于 2017-06-09 15:19:06
你试过:
sudo apt-get install xvfb另一种方法是手动编译包,一种是:
apt-get source xvfb
./configure --prefix=$HOME/myapps
make
make install第三种方法是从源网页.deb下载https://pkgs.org/download/xvfb。
下载后,您可以将它转到下载源的路径:
mv xvfb_1.16.4-1_amd64.deb /var/cache/apt/archives/然后更改目录并执行以下操作:
sudo dpkg -i xvfb_1.16.4-1_amd64.deb仅此而已!
https://stackoverflow.com/questions/44461359
复制相似问题