0

Python で作成したプログラムを実行しようとすると、次のエラーが表示されます。

「ImportError: モジュール名ポリゴンがありません」

ubuntu、python 2.7、および EPD 7.3-1 を使用しています。

Python 用 Polygon モジュールのパッケージと C 拡張をダウンロードするにはどうすればよいですか?

私は試してみました:

sudo apt-get install python-polygon
sudo apt-get install python-polygon2

そして、何も起こりませんでした。

作成者のページからzipファイル「Polygon2-2.0.6.rar」をダウンロードしました。その後、Polygon2-2.0.6.rar を Polygon2-2.0.6 に抽出し、そのフォルダーに移動して python setup.py install を実行します。

私に与える:

jose@jose-Satellite-L845:~/Descargas/Polygon2-2.0.6$ python setup.py install

Using NumPy extension!
running install
running build
running build_py
running build_ext
building 'Polygon.cPolygon' extension

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DDEFAULT_STYLE=STYLE_LIST -DWITH_NUMPY=1 -Isrc -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c src/gpc.c -o build/temp.linux-x86_64-2.7/src/gpc.o

src/gpc.c: In function ‘gpc_read_polygon’:
src/gpc.c:1037:9: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]

fscanf(fp, "%d", &(p->num_contours)); ^

src/gpc.c:1044:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]

 fscanf(fp, "%d", &(p->contour[c].num_vertices));
       ^

src/gpc.c:1047:13: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]

   fscanf(fp, "%d", &(p->hole[c]));
         ^
src/gpc.c:1054:13: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]

   fscanf(fp, "%lf %lf", &(p->contour[c].vertex[v].x),
         ^

src/gpc.c: In function ‘gpc_polygon_clip’:

src/gpc.c:1471:31: warning: ‘dy’ may be used uninitialized in this function [-Wmaybe-uninitialized]

   build_intersection_table(&it, aet, dy);
                           ^

src/gpc.c:1460:12: warning: ‘yt’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     if (edge->top.y == yt)
        ^

src/gpc.c:1328:20: warning: ‘tr’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
                ^

src/gpc.c:1133:34: warning: ‘tl’ may be used uninitialized in this function [-Wmaybe-uninitialized]

int vclass, bl, br, tl, tr; ^

src/gpc.c:1133:30: warning: ‘br’ may be used uninitialized in this function [-Wmaybe-uninitialized]

int vclass, bl, br, tl, tr; ^

src/gpc.c:1133:26: warning: ‘bl’ may be used uninitialized in this function [-Wmaybe-uninitialized]

int vclass, bl, br, tl, tr; ^

src/gpc.c:1330:12: warning: ‘contributing’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     if (contributing)
        ^

src/gpc.c: In function ‘gpc_tristrip_clip’:

src/gpc.c:2131:31: warning: ‘dy’ may be used uninitialized in this function [-Wmaybe-uninitialized]

   build_intersection_table(&it, aet, dy);
                           ^

src/gpc.c:2120:12: warning: ‘yt’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     if (edge->top.y == yt)
        ^

src/gpc.c:1981:20: warning: ‘tr’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
                ^

src/gpc.c:1794:34: warning: ‘tl’ may be used uninitialized in this function [-Wmaybe-uninitialized]

int vclass, bl, br, tl, tr; ^

src/gpc.c:1794:30: warning: ‘br’ may be used uninitialized in this function [-Wmaybe-uninitialized]

int vclass, bl, br, tl, tr; ^

src/gpc.c:1794:26: warning: ‘bl’ may be used uninitialized in this function [-Wmaybe-uninitialized]

int vclass, bl, br, tl, tr; ^

src/gpc.c:1983:12: warning: ‘contributing’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     if (contributing)
        ^

src/gpc.c:2062:16: warning: ‘cft’ may be used uninitialized in this function [-Wmaybe-uninitialized]

         if (cft == LED)
            ^

src/gpc.c:2064:26: warning: ‘cf’ may be used uninitialized in this function [-Wmaybe-uninitialized]

           if (cf->bot.y == yb)
                      ^

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DDEFAULT_STYLE=STYLE_LIST -DWITH_NUMPY=1 -Isrc -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c src/cPolygon.c -o build/temp.linux-x86_64-2.7/src/cPolygon.o

src/cPolygon.c:4:20: fatal error: Python.h: No existe el archivo o el directorio

    #include <Python.h>
                ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

助けてください。前もって感謝します。

4

1 に答える 1

1

zip ファイルをダウンロードし、ファイルを解凍し、フォルダーに cd して、実行python setup.py buildpython setup.py installます。

編集:あなたの答えによると、 python-dev がインストールされている必要があります。

コマンドは次のとおりです。sudo apt-get install python-dev

于 2013-10-28T20:58:51.383 に答える