Ubuntu22.04下给Blender2.79a内置Python3.5安装easydict报错求助
问题:Blender 2.79a Python虚拟环境中pip安装模块报错TypeError
背景
必须使用Blender 2.79a,不确定该错误在Ubuntu 22.04中是否可修复,也可接受在Docker中使用旧版Ubuntu。原pvnet-rendering仓库基于*已停止维护(EOL)*的Ubuntu 16.04。
操作步骤
(base) mona@ada:~$ wget https://download.blender.org/release/Blender2.79/blender-2.79a-linux-glibc219-x86_64.tar.bz2 (base) mona@ada:~$ tar -xvf blender-2.79a-linux-glibc219-x86_64.tar.bz2 (base) mona@ada:~$ git clone https://github.com/zju3dv/pvnet-rendering (base) mona@ada:~$ cd pvnet-rendering/ /home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/python3.5m -m venv pvnet-rendering source pvnet-rendering/bin/activate
运行项目时的错误
(pvnet-rendering) (base) mona@ada:~/pvnet-rendering$ python run.py --type rendering Traceback (most recent call last): File "run.py", line 1, in <module> from config import cfg File "/home/mona/pvnet-rendering/config.py", line 1, in <module> from easydict import EasyDict ImportError: No module named 'easydict'
安装easydict时的报错
(pvnet-rendering) (base) mona@ada:~/pvnet-rendering$ pip install easydict Exception: Traceback (most recent call last): File "/home/mona/pvnet-rendering/pvnet-rendering/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/home/mona/pvnet-rendering/pvnet-rendering/lib/python3.5/site-packages/pip/commands/install.py", line 272, in run with self._build_session(options) as session: File "/home/mona/pvnet-rendering/pvnet-rendering/lib/python3.5/site-packages/pip/basecommand.py", line 69, in _build_session if options.cache_dir else None File "/home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib/python3.5/posixpath.py", line 89, in join genericpath._check_arg_types('join', a, *p) File "/home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib/python3.5/genericpath.py", line 143, in _check_arg_types (funcname, s.__class__.__name__)) from None TypeError: join() argument must be str or bytes, not 'int' Traceback (most recent call last): File "/home/mona/pvnet-rendering/pvnet-rendering/bin/pip", line 11, in <module> sys.exit(main()) File "/home/mona/pvnet-rendering/pvnet-rendering/lib/python3.5/site-packages/pip/__init__.py", line 233, in main return command.main(cmd_args) File "/home/mona/pvnet-rendering/pvnet-rendering/lib/python3.5/site-packages/pip/basecommand.py", line 251, in main timeout=min(5, options.timeout)) as session: File "/home/mona/pvnet-rendering/pvnet-rendering/lib/python3.5/site-packages/pip/basecommand.py", line 69, in _build_session if options.cache_dir else None File "/home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib/python3.5/posixpath.py", line 89, in join genericpath._check_arg_types('join', a, *p) File "/home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib/python3.5/genericpath.py", line 143, in _check_arg_types (funcname, s.__class__.__name__)) from None TypeError: join() argument must be str or bytes, not 'int'
解决方案
方案1:显式指定pip缓存目录
错误源于旧版pip处理缓存目录时,环境变量中存在非字符串类型参数。执行安装时直接指定字符串格式的缓存路径:
pip install easydict --cache-dir /tmp/pip_cache
若临时目录权限受限,可改用用户目录下的路径:
pip install easydict --cache-dir ~/.pip_cache
方案2:升级pip到兼容Python3.5的最新版本
Blender自带的pip版本过旧,先升级pip(同样指定缓存目录规避报错):
pip install --upgrade pip --cache-dir /tmp/pip_cache
升级完成后再安装easydict:
pip install easydict
方案3:Docker部署Ubuntu16.04环境(推荐)
原项目基于EOL的Ubuntu16.04,直接在该环境下运行兼容性最佳:
- 拉取Ubuntu16.04镜像:
docker pull ubuntu:16.04
- 创建并进入容器:
docker run -it --name pvnet-render ubuntu:16.04 /bin/bash
- 在容器内安装git、wget等依赖后,重复原操作步骤即可。
方案4:直接安装到Blender自带Python环境
跳过虚拟环境,使用Blender自带的pip安装模块:
/home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/pip install easydict
运行项目时,确保使用Blender的Python解释器执行:
/home/mona/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin/python run.py --type rendering
内容的提问来源于stack exchange,提问作者Mona Jalal
相关产品推荐
相关产品推荐

