usmannasir / cyberpanel

Cyber Panel - The hosting control panel for OpenLiteSpeed
GNU General Public License v3.0
1.48k stars 577 forks source link

[BUG] cyberpanel cli 2.3.4 @ Django 4.1.1 on Ubuntu throws error ImportError : cannot import name 'ugettext_lazy' #1178

Open adibenc opened 6 months ago

adibenc commented 6 months ago

Describe the bug Executing cyberpanel on cli throws this error:

(CyberCP) root@idcub1-54:/usr/local/CyberCP# cyberpanel -h                                                                                                                                                 
Traceback (most recent call last):                                                                                                                                                                         
  File "/usr/bin/cyberpanel", line 8, in <module>                                                                                                                                                          
    django.setup()                                                                                                                                                                                         
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/__init__.py", line 19, in setup                                                                                                             
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)                                     
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__                                                                                                  
    self._setup(name)                                                                                
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup
    self._wrapped = Settings(settings_module)                                                                                                                                                              
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__                                                                                                    
    mod = importlib.import_module(self.SETTINGS_MODULE)                                                                                                                                                    
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module                                                                                                                             
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                            
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import                        
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load                                 
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked                        
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked                                  
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module                            
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed                       
  File "/usr/local/CyberCP/CyberCP/settings.py", line 14, in <module>
    from django.utils.translation import ugettext_lazy as _                                          
ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/local/CyberCP/lib/python3.10/site-packages/django/utils/translation/__init__.py)                                     
(CyberCP) root@idcub1-54:/usr/local/CyberCP# cyberpanel help                                         

Directly looking at the error at S.O., django generated code throws such an error

  1. https://stackoverflow.com/questions/70656495/importerror-cannot-import-name-ugettext-lazy

Fixing this directly by changing ugettext_lazy to gettext_lazy seems to solve the problem. I don't know if this a django bug or a cyberpanel bug.

To Reproduce What steps did you take when the issue occurred?

  1. Install and use cyberpanel 2.3.4 @ ubuntu 22.04
  2. run cyberpanel command

Expected behavior No error thrown after the installation. We shouldn't need to edit the generated settings.py manually.

Operating system: Ubuntu 22.04 LTS

CyberPanel version: 2.3.4

Additional context If there is anything else that you'd like us to know about this issue that will help us diagnose and troubleshoot more effectively, such as links to forum posts or other discussions, please feel free to share here.

usmannasir commented 5 months ago

Did you manually upgrade django to 4.1.1 ?

adibenc commented 5 months ago

@usmannasir No, all the installation files are original from the repo. It is also stated here btw

https://github.com/usmannasir/cyberpanel/blob/stable/ubuntu-requirments.txt

Currently, i switched to ubuntu 20.04 and the problem seems to not exist.

usmannasir commented 5 months ago

These ones are used: https://github.com/usmannasir/cyberpanel/blob/stable/requirments.txt

How do you install 4.1.1 ?