安装mechanize之后,我似乎无法导入它.
我尝试从pip,easy_install和via python setup.py install这个repo安装:https://github.com/abielr/mechanize.所有这一切都无济于事,因为每次我输入我的Python互动时,我得到:
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mechanize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mechanize
>>>
Run Code Online (Sandbox Code Playgroud)
我之前运行的安装报告说它们已经成功完成,所以我希望导入能够正常工作.可能导致此错误的原因是什么?
我正在尝试在基于Alpine 3.1的docker容器中安装numpy.我正在使用以下Dockerfile:
FROM alpine:3.1
RUN apk add --update make cmake gcc g++ gfortran
RUN apk add --update python py-pip python-dev
RUN pip install cython
RUN pip install numpy
Run Code Online (Sandbox Code Playgroud)
这运行正常,直到pip install numpy我收到以下错误:
error: Command "gcc -fno-strict-aliasing -Os -fomit-frame-pointer -DNDEBUG -Os -fomit-frame-pointer -fPIC -Inumpy/core/include -Ibuild/src.linux-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/include/python2.7 -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -c build/src.linux-x86_64-2.7/numpy/core/src/npymath/ieee754.c -o build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/numpy/core/src/npymath/ieee754.o" failed with exit status 1
Run Code Online (Sandbox Code Playgroud)
easy_install-2.7 numpy 给出了同样的错误.
我缺少任何配置/安装步骤吗?
我有一个真的很难试图安装在一个稳定的数据包的科学配置docker.使用这种主流的相关工具应该会更容易.
以下是曾经工作的Dockerfile,有点破解,从包核心中删除并单独安装,指定,因为据称,更高版本与之冲突.pandaspandas<0.21.0numpy
FROM alpine:3.6
ENV PACKAGES="\
dumb-init \
musl \
libc6-compat \
linux-headers \
build-base \
bash \
git \
ca-certificates \
freetype \
libgfortran \
libgcc \
libstdc++ \
openblas \
tcl \
tk \
libssl1.0 \
"
ENV PYTHON_PACKAGES="\
numpy \
matplotlib \
scipy \
scikit-learn \
nltk \
"
RUN apk add --no-cache --virtual build-dependencies python3 \
&& apk add --virtual build-runtime \
build-base python3-dev openblas-dev …Run Code Online (Sandbox Code Playgroud) 我是 Docker 新手,一直在尝试将 python 脚本包装在容器中,但在我的对接 alpine 实例上安装 scipy 0.17.0(作为 scikit-learn 的依赖项)时遇到错误我一直没能找到答案。
我的 Dockerfile:
FROM python:alpine
COPY . /app
WORKDIR /app
RUN apk add --no-cache python3-dev libstdc++ && \
apk add --no-cache g++ && \
ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN pip3 install -r requirements.txt
CMD python ./python_script.py
Run Code Online (Sandbox Code Playgroud)
我的requirements.txt文件:
numpy==1.16.5
pandas==0.25.2
scikit-learn==0.21.3
Run Code Online (Sandbox Code Playgroud)
输出:
Sending build context to Docker daemon 1.097GB
Step 1/7 : FROM python:alpine
---> 204216b3821e
Step 2/7 : COPY . /app
---> 1e06520a2b68
Step 3/7 : WORKDIR /app
---> Running …Run Code Online (Sandbox Code Playgroud)