[已解决]:ModuleNotFoundError: No module named ‘Polygon‘

问题:没安装polygon库

以下指令均不能正确安装:

pip install polygon
pip install python-polygon
pip install Polygon3
# 或者采用清华镜像
pip install Polygon3 -i https://pypi.tuna.tsinghua.edu.cn/simple

[已解决]:ModuleNotFoundError: No module named ‘Polygon‘_第1张图片

------------------------------

20210220:

最近不知为何python3.7和python3.8都不能正常安装了

t# python3.7 -m pip install Polygon3 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting Polygon3
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/73/a0/d07a4f3e80ed7020a33f3111db217f54ac44a485ff45da3c21ce49f65041/Polygon3-3.0.8.tar.gz (71 kB)
Using legacy 'setup.py install' for Polygon3, since package 'wheel' is not installed.
Installing collected packages: Polygon3
    Running setup.py install for Polygon3 ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ge62c6la/polygon3_baebf572d53c4160aa6a115dc462c486/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ge62c6la/polygon3_baebf572d53c4160aa6a115dc462c486/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-z49z6ctn/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/Polygon3
         cwd: /tmp/pip-install-ge62c6la/polygon3_baebf572d53c4160aa6a115dc462c486/
    Complete output (72 lines):
    Using NumPy extension!
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/Polygon
    copying Polygon/Shapes.py -> build/lib.linux-x86_64-3.7/Polygon
    copying Polygon/__init__.py -> build/lib.linux-x86_64-3.7/Polygon
    copying Polygon/Utils.py -> build/lib.linux-x86_64-3.7/Polygon
    copying Polygon/IO.py -> build/lib.linux-x86_64-3.7/Polygon
    running build_ext
    building 'Polygon.cPolygon' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DDEFAULT_STYLE=STYLE_LIST -DWITH_NUMPY=1 -Isrc -I/usr/local/lib/python3.7/dist-packages/numpy/core/include -I/usr/include/python3.7m -c src/gpc.c -o build/temp.linux-x86_64-3.7/src/gpc.o
    src/gpc.c: In function ‘gpc_polygon_clip’:
    src/gpc.c:1471:7: warning: ‘dy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           build_intersection_table(&it, aet, dy);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/gpc.c:1672:12: warning: ‘yt’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if ((edge->top.y == yt) && succ_edge)
                ^
    src/gpc.c:1133:38: warning: ‘tr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       int            vclass, bl, br, tl, tr;
                                          ^~
    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:1328:50: warning: ‘bl’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
                                                  ~~~~^~~~~
    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:7: warning: ‘dy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           build_intersection_table(&it, aet, dy);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/gpc.c:2361:12: warning: ‘yt’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if ((edge->top.y == yt) && succ_edge)
                ^
    src/gpc.c:1794:38: warning: ‘tr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       int            vclass, bl, br, tl, tr;
                                          ^~
    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:1981:50: warning: ‘bl’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
                                                  ~~~~^~~~~
    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 -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DDEFAULT_STYLE=STYLE_LIST -DWITH_NUMPY=1 -Isrc -I/usr/local/lib/python3.7/dist-packages/numpy/core/include -I/usr/include/python3.7m -c src/cPolygon.c -o build/temp.linux-x86_64-3.7/src/cPolygon.o
    src/cPolygon.c:4:10: fatal error: Python.h: No such file or directory
     #include 
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ge62c6la/polygon3_baebf572d53c4160aa6a115dc462c486/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ge62c6la/polygon3_baebf572d53c4160aa6a115dc462c486/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-z49z6ctn/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/Polygon3 Check the logs for full command output.

只有python3.6能正常安装 ,原因:缺失依赖库,对于python3.x, 安装对应的依赖库即可

apt-get install python3.7-dev  

再次执行就可以了:

pip install Polygon3 -i https://pypi.tuna.tsinghua.edu.cn/simple

 

你可能感兴趣的:(填坑之旅)