NameError: name 'reload' is not defined
来源:17-1 快速升级到python3.6+django2.0
szuxxy
2019-11-12
(szuenv) [root@VM_0_6_centos szumooc190528]# python -V
Python 3.6.8
(szuenv) [root@VM_0_6_centos szumooc190528]# ll
total 36
drwxr-xr-x 5 root root 4096 Nov 12 10:32 apps
drwxr-xr-x 3 root root 4096 Nov 12 10:32 extra_apps
drwxr-xr-x 3 root root 4096 Nov 12 10:32 image
-rw-r--r-- 1 root root 539 Nov 12 10:32 manage.py
-rw-r--r-- 1 root root 3274 Nov 12 10:32 README.md
-rw-r--r-- 1 root root 568 Nov 12 10:32 requirements.txt
drwxr-xr-x 7 root root 4096 Nov 12 10:32 static
drwxr-xr-x 3 root root 4096 Nov 12 10:49 szumooc
drwxr-xr-x 2 root root 4096 Nov 12 10:32 templates
(szuenv) [root@VM_0_6_centos szumooc190528]# python3 manage.py runservice
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/root/envs/szuenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/root/envs/szuenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/root/envs/szuenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/root/envs/szuenv/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/root/envs/szuenv/lib/python3.6/site-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/root/envs/szuenv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/root/envs/szuenv/lib/python3.6/site-packages/xadmin/__init__.py", line 4, in <module>
from xadmin.sites import AdminSite, site
File "/root/envs/szuenv/lib/python3.6/site-packages/xadmin/sites.py", line 9, in <module>
reload(sys)
NameError: name 'reload' is not defined
我这边在本地能正常跑,然后到centos 里就这样了。按照这个错误查了下,比如这里https://blog.csdn.net/CuiXiaoBo521/article/details/75036127。也有人问过类似的问题https://coding.imooc.com/learn/questiondetail/66154.html。but…。 操作流程就是我把本地的代码提交到github上,然后在centos里把代码git clone下来,进入去执行run的命令。感觉需要老师来看看呀。
11141411
我在本地pip uninstall xadmin了,然后把xadmin的文件夹弄到了extra_app文件夹下了(也就 是源码安装),并且在settings.py里把sys.path.insert(0, os.path.join(BASE_DIR, ‘extra_apps’))了。然后run了一下,发现:
后来都解决了。直到能正常的跑。但是发现我在添加课程的时候会报错:
查了下,看见各种版本说怎么解决的。
比如按这个操作是没有效果的:https://blog.csdn.net/jingyu333/article/details/82287018.
这个依旧是没效果的:https://www.cnblogs.com/louzi/p/9778439.html。
比如这个:stackoverflow
另外这种源码感觉比pip的遇到的坑我多些啊。只是pip有个NameError: name ‘reload’ is not defined的错。
1回答
-
这个看起来是xadmin的兼容问题 你的django版本是多少? xadmin是在哪里下载的? django版本是多少?
082019-12-06
相似问题