欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

在导入NVIDIA的apex库时报错 ImportError cannot import name ‘UnencryptedCookieSessionFactoryConfig‘ from

发布时间:2025/3/8 编程问答 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 在导入NVIDIA的apex库时报错 ImportError cannot import name ‘UnencryptedCookieSessionFactoryConfig‘ from 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

在导入NVIDIA的apex库时报错 ImportError: cannot import name ‘UnencryptedCookieSessionFactoryConfig’ from ‘pyramid.session’ (unknown location)

报错

在使用NVIDIA的apex库时报错 ImportError: cannot import name ‘UnencryptedCookieSessionFactoryConfig’ from ‘pyramid.session’ (unknown location)

笔者一开始是使用的pip直接来安装apex:

pip install apex

但是在运行时报错:

Traceback (most recent call last):File "main.py", line 10, in <module>import apexFile "/home/ps/anaconda3/envs/JJ_env/lib/python3.8/site-packages/apex/__init__.py", line 13, in <module>from pyramid.session import UnencryptedCookieSessionFactoryConfig ImportError: cannot import name 'UnencryptedCookieSessionFactoryConfig' from 'pyramid.session' (unknown location)

经调查,原因是pip直接安装的apex只是和我们想要安装的NVIDIA的apex库重名,但其实根本不是一回事儿。、

解决方案

从NVIDIA的github安装apex库

git clone https://github.com/NVIDIA/apex cd apex# 同时安装C++扩展 pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./# Apex 同样支持 Python-only build (required with Pytorch 0.4) viapip install -v --no-cache-dir ./

笔者使用带C++扩展的完全安装时同样会报错,使用仅python安装时显示成功。

前者关键报错信息为:

ERROR: Command errored out with exit status 1: /users4/zsun/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-v0deounv/setup.py'"'"'; __file__='"'"'/tmp/p ip-req-build-v0deounv/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --cpp_e xt --cuda_ext install --record /tmp/pip-record-rce1cb4d/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

评论区有朋友指出C++扩展安装的问题可能是由于CUDA版本的原因,大家可参考。

参考:

https://stackoverflow.com/questions/66610378/unencryptedcookiesessionfactoryconfig-error-when-importing-apex

https://blog.csdn.net/ccbrid/article/details/103207676/

总结

以上是生活随笔为你收集整理的在导入NVIDIA的apex库时报错 ImportError cannot import name ‘UnencryptedCookieSessionFactoryConfig‘ from的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。