无法使用 pip 安装包 bpy
Cannot install package bpy using pip
问题描述:
在 VS Code 中,运行 命令 pip install bpy(如 https://pypi.org/project/bpy/ 所示)并得到以下错误消息:
PS C:\Users\(...)\Local\Programs\Python\Python38> pip install bpy
Collecting bpy
Using cached bpy-0.0.0a0.tar.gz (19 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\(...)\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\setup.py'"'"'; __file__='"'"'C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\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 'C:\Users\(...)\Local\Temp\pip-pip-egg-info-0pdk7e9q'
cwd: C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\
Complete output (16 lines):
Traceback (most recent call last):
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 342, in find_cookie
codec = lookup(encoding)
LookupError: unknown encoding: future_fstrings
During handling of the above exception, another exception occurred:
File "<string>", line 1, in <module>
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 394, in open
encoding, lines = detect_encoding(buffer.readline)
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 381, in detect_encoding
encoding = find_cookie(second)
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 350, in find_cookie
raise SyntaxError(msg)
SyntaxError: unknown encoding for 'C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\setup.py': future_fstrings
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. code here
-------- 我试过的(没有成功):------
安装轮子(pip install wheel),然后从pypi.org下载包手动安装:
pip 安装'C:\Users(...)\Downloads\bpy-2.82.1.tar.gz'
遇到同样的错误。
-------- 结论:------
不能在 Blender 之外使用 bpy。我在 Blender Stack Exchange 上的另一个 post 上找到了一些解决方法(我还没有尝试过)
感谢 Anand 和 phd 提供的非常有用的链接!
不幸的是,‘bpy’模块不能在 Blender 之外使用。
这里有更多详细信息:https://creativepolygon.com/development/starting-with-bpy-blender-python-part-1-installation
据我了解,实际上可以 运行 在 blender 之外进行 bpy,并且声称其他信息是为旧版本编写的。我不得不承认,我仍在安装 bpy,这不是一件容易的事,我还无法验证这一点。
在您的情况下,缺少 pip 模块。您可以使用 pip install future_fstrings
安装它。查看 https://pypi.org/project/bpy/ 了解更多指南。
编辑:我能够在 Windows 和 Linux 下安装 bpy。它在 Linux 上抛出一些错误,但在 Windows 下工作正常。绝对独立工作!
我试了很多次,发现使用3.7.6的Python版本和20.2.4的pip版本,我能够通过pip安装bpy版本-2.82.1安装 bpy。我正在使用 Windows 10 和 Anaconda 提示符。
TL:DR- 从预制轮安装,而不是从标准 pip install bpy && bpy_post_install
在 macOS 上安装错误:
过去 8 小时左右我一直在尝试安装它。
到目前为止我的安装步骤:
- 我按照 blender.org
上的说明从源代码构建了搅拌机应用程序
- 根据 bpy github 存储库,bpy 依赖于 bpy-build(尽管它不在先决条件中)。
- bpy-build github 存储库没有很好的安装说明,setup.py 脚本专门将 OS 声明为 windows。所以,我基本上只是跳过了这个 - 安装失败的可能原因。
- 在两次不同的尝试中,我同时使用了 pyenv 和 virtualenv,以创建一个 python 3.7 开发环境。在
setup.py
的 运行 期间,两者都导致了 pip install bpy
的挂起安装。 pip 安装的实际错误是:
Collecting bpy
Using cached https://files.pythonhosted.org/packages/4b/ed/ba6092b691acc5b157891421d9fde4a9dd5dcc8a8b93a4e8119fec261391/bpy-2.82.1.tar.gz
Installing collected packages: bpy
Running setup.py install for bpy ... error
ERROR: Command errored out with exit status 1:
command: /<path-to-venv>/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"'; __file__='"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-record-ti3q9j4a/install-record.txt --single-version-externally-managed --compile --install-headers /<path-to-venv>/venv/include/site/python3.7/bpy
cwd: /private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/
Complete output (58 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/blenderpy
copying blenderpy/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/blenderpy
copying blenderpy/pre_uninstall.py -> build/lib.macosx-10.9-x86_64-3.7/blenderpy
copying blenderpy/post_install.py -> build/lib.macosx-10.9-x86_64-3.7/blenderpy
running build_ext
Preparing the build environment
Searching for compatible Blender online (this will take a while)
Found compatible Blender version 2.82
Cloning Blender source from git (this will take a while)
Cloning precompiled libs from svn (this will take a while)
cmake -DWITH_PYTHON_INSTALL=OFF -DWITH_PYTHON_MODULE=ON -DWITH_OPENMP=OFF -DWITH_AUDASPACE=OFF -S/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/blender -B/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/build
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detected OS X 11.3 and Xcode 12. at /Applications/Xcode.app
-- OSX_SYSROOT_PREFIX: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
-- Setting deployment target to 10.11, lower versions are not supported
CMake Warning at CMakeLists.txt:580 (message):
WITH_OPENAL requires WITH_AUDASPACE which is disabled
CMake Warning at CMakeLists.txt:584 (message):
WITH_JACK requires WITH_AUDASPACE which is disabled
-- WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now
-- Performing Test SUPPORT_SSE_BUILD
-- Performing Test SUPPORT_SSE_BUILD - Success
-- SSE Support: detected.
-- Performing Test SUPPORT_SSE2_BUILD
-- Performing Test SUPPORT_SSE2_BUILD - Success
-- SSE2 Support: detected.
-- Found Git: /usr/bin/git (found version "2.30.1 (Apple Git-130)")
CMake Error at build_files/cmake/platform/platform_apple.cmake:38 (message):
Mac OSX requires pre-compiled libs at:
'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/blender/../lib/darwin'
Call Stack (most recent call first):
CMakeLists.txt:808 (include)
-- Configuring incomplete, errors occurred!
See also "/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/build/CMakeFiles/CMakeOutput.log".
See also "/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/build/CMakeFiles/CMakeError.log".
error: command 'cmake' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /<path to venv>/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"'; __file__='"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-record-ti3q9j4a/install-record.txt --single-version-externally-managed --compile --install-headers /<path to venv>/venv/include/site/python3.7/bpy Check the logs for full command output.
**** 突破 ****
在写这篇文章时,我注意到 bpy github 页面中的选项是通过预构建轮而不是通常的 pip install bpy && bpy_post_install
安装。你必须去一些 'sketchy' 网站下载文件,但在我下载并安装它之后,我能够 运行 在 blender 应用程序之外运行 blender 脚本!!
我猜你无法安装 bpy,因为你正在通过 python 3.8 版本安装 bpy。
您已经降级 python version to 3.7
查看https://pypi.org/project/bpy/
然后你可以看到bpy模块需要Python >=3.7, <3.8
的版本
问题描述: 在 VS Code 中,运行 命令 pip install bpy(如 https://pypi.org/project/bpy/ 所示)并得到以下错误消息:
PS C:\Users\(...)\Local\Programs\Python\Python38> pip install bpy
Collecting bpy
Using cached bpy-0.0.0a0.tar.gz (19 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\(...)\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\setup.py'"'"'; __file__='"'"'C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\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 'C:\Users\(...)\Local\Temp\pip-pip-egg-info-0pdk7e9q'
cwd: C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\
Complete output (16 lines):
Traceback (most recent call last):
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 342, in find_cookie
codec = lookup(encoding)
LookupError: unknown encoding: future_fstrings
During handling of the above exception, another exception occurred:
File "<string>", line 1, in <module>
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 394, in open
encoding, lines = detect_encoding(buffer.readline)
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 381, in detect_encoding
encoding = find_cookie(second)
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 350, in find_cookie
raise SyntaxError(msg)
SyntaxError: unknown encoding for 'C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\setup.py': future_fstrings
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. code here
-------- 我试过的(没有成功):------
安装轮子(pip install wheel),然后从pypi.org下载包手动安装: pip 安装'C:\Users(...)\Downloads\bpy-2.82.1.tar.gz' 遇到同样的错误。
-------- 结论:------
不能在 Blender 之外使用 bpy。我在 Blender Stack Exchange 上的另一个 post 上找到了一些解决方法(我还没有尝试过) 感谢 Anand 和 phd 提供的非常有用的链接!
不幸的是,‘bpy’模块不能在 Blender 之外使用。
这里有更多详细信息:https://creativepolygon.com/development/starting-with-bpy-blender-python-part-1-installation
据我了解,实际上可以 运行 在 blender 之外进行 bpy,并且声称其他信息是为旧版本编写的。我不得不承认,我仍在安装 bpy,这不是一件容易的事,我还无法验证这一点。
在您的情况下,缺少 pip 模块。您可以使用 pip install future_fstrings
安装它。查看 https://pypi.org/project/bpy/ 了解更多指南。
编辑:我能够在 Windows 和 Linux 下安装 bpy。它在 Linux 上抛出一些错误,但在 Windows 下工作正常。绝对独立工作!
我试了很多次,发现使用3.7.6的Python版本和20.2.4的pip版本,我能够通过pip安装bpy版本-2.82.1安装 bpy。我正在使用 Windows 10 和 Anaconda 提示符。
TL:DR- 从预制轮安装,而不是从标准 pip install bpy && bpy_post_install
在 macOS 上安装错误:
过去 8 小时左右我一直在尝试安装它。
到目前为止我的安装步骤:
- 我按照 blender.org 上的说明从源代码构建了搅拌机应用程序
- 根据 bpy github 存储库,bpy 依赖于 bpy-build(尽管它不在先决条件中)。
- bpy-build github 存储库没有很好的安装说明,setup.py 脚本专门将 OS 声明为 windows。所以,我基本上只是跳过了这个 - 安装失败的可能原因。
- 在两次不同的尝试中,我同时使用了 pyenv 和 virtualenv,以创建一个 python 3.7 开发环境。在
setup.py
的 运行 期间,两者都导致了pip install bpy
的挂起安装。 pip 安装的实际错误是:
Collecting bpy
Using cached https://files.pythonhosted.org/packages/4b/ed/ba6092b691acc5b157891421d9fde4a9dd5dcc8a8b93a4e8119fec261391/bpy-2.82.1.tar.gz
Installing collected packages: bpy
Running setup.py install for bpy ... error
ERROR: Command errored out with exit status 1:
command: /<path-to-venv>/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"'; __file__='"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-record-ti3q9j4a/install-record.txt --single-version-externally-managed --compile --install-headers /<path-to-venv>/venv/include/site/python3.7/bpy
cwd: /private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/
Complete output (58 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/blenderpy
copying blenderpy/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/blenderpy
copying blenderpy/pre_uninstall.py -> build/lib.macosx-10.9-x86_64-3.7/blenderpy
copying blenderpy/post_install.py -> build/lib.macosx-10.9-x86_64-3.7/blenderpy
running build_ext
Preparing the build environment
Searching for compatible Blender online (this will take a while)
Found compatible Blender version 2.82
Cloning Blender source from git (this will take a while)
Cloning precompiled libs from svn (this will take a while)
cmake -DWITH_PYTHON_INSTALL=OFF -DWITH_PYTHON_MODULE=ON -DWITH_OPENMP=OFF -DWITH_AUDASPACE=OFF -S/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/blender -B/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/build
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detected OS X 11.3 and Xcode 12. at /Applications/Xcode.app
-- OSX_SYSROOT_PREFIX: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
-- Setting deployment target to 10.11, lower versions are not supported
CMake Warning at CMakeLists.txt:580 (message):
WITH_OPENAL requires WITH_AUDASPACE which is disabled
CMake Warning at CMakeLists.txt:584 (message):
WITH_JACK requires WITH_AUDASPACE which is disabled
-- WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now
-- Performing Test SUPPORT_SSE_BUILD
-- Performing Test SUPPORT_SSE_BUILD - Success
-- SSE Support: detected.
-- Performing Test SUPPORT_SSE2_BUILD
-- Performing Test SUPPORT_SSE2_BUILD - Success
-- SSE2 Support: detected.
-- Found Git: /usr/bin/git (found version "2.30.1 (Apple Git-130)")
CMake Error at build_files/cmake/platform/platform_apple.cmake:38 (message):
Mac OSX requires pre-compiled libs at:
'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/blender/../lib/darwin'
Call Stack (most recent call first):
CMakeLists.txt:808 (include)
-- Configuring incomplete, errors occurred!
See also "/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/build/CMakeFiles/CMakeOutput.log".
See also "/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/build/temp.macosx-10.9-x86_64-3.7/build/CMakeFiles/CMakeError.log".
error: command 'cmake' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /<path to venv>/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"'; __file__='"'"'/private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-install-m6rixhki/bpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4n/wsjhxhbn0pb11r7cyqcvtxcc0000gn/T/pip-record-ti3q9j4a/install-record.txt --single-version-externally-managed --compile --install-headers /<path to venv>/venv/include/site/python3.7/bpy Check the logs for full command output.
**** 突破 ****
在写这篇文章时,我注意到 bpy github 页面中的选项是通过预构建轮而不是通常的 pip install bpy && bpy_post_install
安装。你必须去一些 'sketchy' 网站下载文件,但在我下载并安装它之后,我能够 运行 在 blender 应用程序之外运行 blender 脚本!!
我猜你无法安装 bpy,因为你正在通过 python 3.8 版本安装 bpy。
您已经降级 python version to 3.7
查看https://pypi.org/project/bpy/
然后你可以看到bpy模块需要Python >=3.7, <3.8