'`UnencryptedCookieSessionFactoryConfig` error when importing Apex

I'm trying to use Apex and whenever I try to import it (or anything involving it) I get the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/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)

I have the Pyramid library installed and importing that causes no issues. My Python version is 3.8.5 and my OS is Ubuntu 18.04.5.

I've tried searching online but haven't been able to find a satisfactory solution and was hoping to know if anyone who is familiar would be able to provide some tips on what the problem may be and what I can do. Thanks.



Solution 1:[1]

I get the same issue if I use pip install apex.

It turns out that apex on pypi has nothing to do with NVIDIA's apex and is a totally unrelated, really old package.

To install NVIDIA's apex do:

git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir \
--global-option="--cpp_ext" --global-option="--cuda_ext" ./

For more info see doc.

Solution 2:[2]

The code below worked for me

git clone https://github.com/NVIDIA/apex
cd apex
python setup.py install

Solution 3:[3]

This will work:

pip uninstall apex

Solution 4:[4]

Below code has worked for me in colab instance

!git clone https://github.com/NVIDIA/apex
%cd apex
!python3 setup.py install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 sammens19
Solution 3 Greg Tarr
Solution 4 Somex Gupta