安装 AssimpCy
Installing AssimpCy
对于学校项目,我必须使用 Python 的 OpenGL 库。
这是我老师给出的代码的导入部分:
import OpenGL.GL as GL # standard Python OpenGL wrapper
import glfw # lean window system wrapper for OpenGL
import numpy as np # all matrix manipulations & OpenGL args
import assimpcy
我成功安装了OpenGL、glfw和numpy的库,但是我无法安装assimpcy。
用 pip 安装它不起作用,我得到这个错误:
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i0q0sk1z/AssimpCy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i0q0sk1z/AssimpCy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-i0q0sk1z/AssimpCy/
Complete output (26 lines):
running egg_info
creating pip-egg-info/AssimpCy.egg-info
writing pip-egg-info/AssimpCy.egg-info/PKG-INFO
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-i0q0sk1z/AssimpCy/setup.py", line 58, in <module>
setup(
File "/usr/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 289, in run
writer(self, ep.name, os.path.join(self.egg_info, ep.name))
File "/usr/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 621, in write_pkg_info
metadata.write_pkg_info(cmd.egg_info)
File "/usr/lib/python3.8/distutils/dist.py", line 1117, in write_pkg_info
self.write_pkg_file(pkg_info)
File "/usr/lib/python3.8/site-packages/setuptools/dist.py", line 167, in write_pkg_file
long_desc = rfc822_escape(self.get_long_description())
File "/usr/lib/python3.8/distutils/util.py", line 475, in rfc822_escape
lines = header.split('\n')
TypeError: a bytes-like object is required, not 'str'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
然后我尝试自己编译它,所以我按照这个教程:https://assimpcy.readthedocs.io/en/latest/install.html
我下载了已编译并安装的 Assimp,下载了 AssimpCy 的 github 存储库,但是当我启动它时:
python setup.py build_ext -I'/home/alexis/Documents/assimp-5.0.1/include/assimp' -L'/home/alexis/Documents/AssimpCy'
我收到这个错误:
running build_ext
building 'assimpcy.all' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC -I/usr/lib/python3.8/site-packages/numpy/core/include -I/usr/include/assimp -I/usr/local/include/assimp -I/home/alexis/Documents/assimp-5.0.1/include/assimp -I/usr/include/python3.8 -c ./assimpcy/all.cpp -o build/temp.linux-x86_64-3.8/./assimpcy/all.o -w -O3 -fopenmp -std=c++0x
In the file included from /home/alexis/Documents/assimp-5.0.1/include/assimp/types.h:59,
from ./assimpcy/all.cpp:537:
/home/alexis/Documents/assimp-5.0.1/include/assimp/defs.h:53:10: fatal error: assimp/config.h : No file or folder of this kind
53 | #include <assimp/config.h>
| ^~~~~~~~~~~~~~~~~
compilation over.
error: command 'gcc' failed with exit status 1
您有什么想法可以帮到您吗?
我猜这个问题是由错误的包含文件夹引起的。而不是这个
python setup.py build_ext -I'/home/alexis/Documents/assimp-5.0.1/include/assimp' -L'/home/alexis/Documents/AssimpCy'
尝试使用这个
python setup.py build_ext -I'/home/alexis/Documents/assimp-5.0.1/include/' -L'/home/alexis/Documents/AssimpCy'
所有 public 包含都位于文件夹 include/assimp 中,将按以下方式包含:
#include <assimp/types.h>
因此,将 assimp-prefix 添加到 include 将为 public include 设置错误的位置。将 include 设置为 include/assimp 时,include 语句将失败。
好的,我终于找到了错误。似乎是在安装 Assimp 的过程中出错了。我刚刚重新安装了 Assimp 并运行 python setup.py build_ext
并且成功了。
对于学校项目,我必须使用 Python 的 OpenGL 库。
这是我老师给出的代码的导入部分:
import OpenGL.GL as GL # standard Python OpenGL wrapper
import glfw # lean window system wrapper for OpenGL
import numpy as np # all matrix manipulations & OpenGL args
import assimpcy
我成功安装了OpenGL、glfw和numpy的库,但是我无法安装assimpcy。
用 pip 安装它不起作用,我得到这个错误:
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i0q0sk1z/AssimpCy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i0q0sk1z/AssimpCy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-i0q0sk1z/AssimpCy/
Complete output (26 lines):
running egg_info
creating pip-egg-info/AssimpCy.egg-info
writing pip-egg-info/AssimpCy.egg-info/PKG-INFO
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-i0q0sk1z/AssimpCy/setup.py", line 58, in <module>
setup(
File "/usr/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 289, in run
writer(self, ep.name, os.path.join(self.egg_info, ep.name))
File "/usr/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 621, in write_pkg_info
metadata.write_pkg_info(cmd.egg_info)
File "/usr/lib/python3.8/distutils/dist.py", line 1117, in write_pkg_info
self.write_pkg_file(pkg_info)
File "/usr/lib/python3.8/site-packages/setuptools/dist.py", line 167, in write_pkg_file
long_desc = rfc822_escape(self.get_long_description())
File "/usr/lib/python3.8/distutils/util.py", line 475, in rfc822_escape
lines = header.split('\n')
TypeError: a bytes-like object is required, not 'str'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
然后我尝试自己编译它,所以我按照这个教程:https://assimpcy.readthedocs.io/en/latest/install.html
我下载了已编译并安装的 Assimp,下载了 AssimpCy 的 github 存储库,但是当我启动它时:
python setup.py build_ext -I'/home/alexis/Documents/assimp-5.0.1/include/assimp' -L'/home/alexis/Documents/AssimpCy'
我收到这个错误:
running build_ext
building 'assimpcy.all' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC -I/usr/lib/python3.8/site-packages/numpy/core/include -I/usr/include/assimp -I/usr/local/include/assimp -I/home/alexis/Documents/assimp-5.0.1/include/assimp -I/usr/include/python3.8 -c ./assimpcy/all.cpp -o build/temp.linux-x86_64-3.8/./assimpcy/all.o -w -O3 -fopenmp -std=c++0x
In the file included from /home/alexis/Documents/assimp-5.0.1/include/assimp/types.h:59,
from ./assimpcy/all.cpp:537:
/home/alexis/Documents/assimp-5.0.1/include/assimp/defs.h:53:10: fatal error: assimp/config.h : No file or folder of this kind
53 | #include <assimp/config.h>
| ^~~~~~~~~~~~~~~~~
compilation over.
error: command 'gcc' failed with exit status 1
您有什么想法可以帮到您吗?
我猜这个问题是由错误的包含文件夹引起的。而不是这个
python setup.py build_ext -I'/home/alexis/Documents/assimp-5.0.1/include/assimp' -L'/home/alexis/Documents/AssimpCy'
尝试使用这个
python setup.py build_ext -I'/home/alexis/Documents/assimp-5.0.1/include/' -L'/home/alexis/Documents/AssimpCy'
所有 public 包含都位于文件夹 include/assimp 中,将按以下方式包含:
#include <assimp/types.h>
因此,将 assimp-prefix 添加到 include 将为 public include 设置错误的位置。将 include 设置为 include/assimp 时,include 语句将失败。
好的,我终于找到了错误。似乎是在安装 Assimp 的过程中出错了。我刚刚重新安装了 Assimp 并运行 python setup.py build_ext
并且成功了。