Running odoo in Debugging VSCode and found error ModuleNotFoundError: No module named 'stdnum' - - -
Running odoo in Debugging VSCode and found error ModuleNotFoundError: No module named 'stdnum' - - -
我使用 VSCode 作为我的 IDE 用于开发 odoo,现在 运行 使用开始 > 调试 (F5)
当 运行在网络浏览器中 localhost:8069(默认)然后出现
内部服务器错误并且在终端VSCode中有错误:
Traceback (most recent call last):
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/registry.py", line 63, in __new__
return cls.registries[db_name]
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/tools/func.py", line 71, in wrapper
return func(self, *args, **kwargs)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/tools/lru.py", line 34, in __getitem__
a = self.d[obj]
KeyError: 'usu02' #this my database name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/teguhteja/P/OdooProject/odoo1/.venv/lib/python3.7/site-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/home/teguhteja/P/OdooProject/odoo1/.venv/lib/python3.7/site-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/service/server.py", line 441, in app
return self.app(e, s)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/service/wsgi_server.py", line 113, in application
return application_unproxied(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/service/wsgi_server.py", line 88, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/http.py", line 1306, in __call__
return self.dispatch(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/http.py", line 1272, in __call__
return self.app(environ, start_wrapped)
File "/home/teguhteja/P/OdooProject/odoo1/.venv/lib/python3.7/site-packages/werkzeug/middleware/shared_data.py", line 260, in __call__
return self.app(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/http.py", line 1461, in dispatch
odoo.registry(db).check_signaling()
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/__init__.py", line 104, in registry
return modules.registry.Registry(database_name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/registry.py", line 65, in __new__
return cls.new(db_name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/loading.py", line 457, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/loading.py", line 349, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/loading.py", line 179, in load_module_graph
load_openerp_module(package.name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/module.py", line 385, in load_openerp_module
__import__('odoo.addons.' + module_name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/addons/base_vat/__init__.py", line 4, in <module>
from . import models
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/addons/base_vat/models/__init__.py", line 6, in <module>
from . import res_partner
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/addons/base_vat/models/res_partner.py", line 7, in <module>
import stdnum
ModuleNotFoundError: No module named 'stdnum' - - -
我尝试搜索并在此处找到
- How to fix "ModuleNotFoundError: No module named 'python-stdnum'"
- UnicodeDecodeError: 'charmap' codec| Error during installation of pip python-stdnum==1.8
然后
pip install python-stdnum == 1.17 # new version
但结果是一样的。然后我查看我的 pip 列表
pip list
appdirs 1.4.4
attrs 21.2.0
Babel 2.6.0
backcall 0.2.0
bcrypt 3.2.0
beautifulsoup4 4.10.0
cached-property 1.5.2
certifi 2021.10.8
cffi 1.15.0
chardet 3.0.4
decorator 4.3.0
defusedxml 0.7.1
docutils 0.14
ebaysdk 2.1.5
freezegun 0.3.11
future 0.18.2
gevent 1.5.0
greenlet 0.4.15
html2text 2018.1.9
idna 2.6
ipdb 0.13.9
ipython 7.30.1
isodate 0.6.0
jedi 0.18.1
Jinja2 2.10.1
libsass 0.17.0
lxml 4.3.2
Mako 1.0.7
MarkupSafe 1.1.0
matplotlib-inline 0.1.3
num2words 0.5.6
ofxparse 0.19
parso 0.8.3
passlib 1.7.1
pexpect 4.8.0
pickleshare 0.7.5
Pillow 5.4.1
pip 21.3.1
polib 1.1.0
prompt-toolkit 3.0.24
psutil 5.8.0
psycopg2 2.7.7
ptyprocess 0.7.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pydot 1.4.1
Pygments 2.10.0
pyodbc 4.0.32
pyparsing 3.0.6
PyPDF2 1.26.0
pyserial 3.4
python-dateutil 2.7.3
python-ldap 3.1.0
python-stdnum 1.17
pytz 2019.1
pyusb 1.0.2
pyzk 0.9
qrcode 6.1
reportlab 3.5.13
requests 2.21.0
requests-toolbelt 0.9.1
setuptools 41.2.0
six 1.16.0
soupsieve 2.3.1
toml 0.10.2
traitlets 5.1.1
urllib3 1.24.3
vobject 0.9.6.1
wcwidth 0.2.5
Werkzeug 0.16.1
wheel 0.37.0
xlrd 1.1.0
XlsxWriter 1.1.2
xlwt 1.3.0
我发现我的 python-stdnum 已经安装
我怀疑我的问题在 launch.json vscode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Odoo",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"python": "${command:python.interpreterPath}",
// "console": "externalTerminal",
"program": "${workspaceRoot}/odoo-14.0/odoo-server",
"args": [
"--config=${workspaceRoot}/conf/odoo-training14.conf",
],
"cwd": "${workspaceRoot}",
// "env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"RedirectOutput"
]
}
]
}
如何解决我的问题?
备选方案
目前我 运行 odoo 使用下面的命令并使用 ipdb
进行调试
python3 odoo-14.0/odoo-server -c conf/odoo-training14.conf
尝试了几天后才发现项目中的 pip 和 python 由于更新而没有指向 .venv 而是指向 anaconda。当错误
no module stdnum
实际上 pip 有问题所以请确保你的 pip 路径为 which pip 或 which python
- 通过删除 .venv 文件夹解决 .venv 不起作用的问题,在 python 中创建 venv,然后重新安装所有要求
rm .venv
python3 -m venv .venv
source .venv/bin/activate.fish
python3 -m pip install --upgrade pip # upgrade pip
pip install -r requirements.txt
- 因为它使用 vscode 确保你的解释器
ctrl + shift + P 然后
Python : Select Interpreter
并选择您的 .venv
之后就可以正常调试了
我使用 VSCode 作为我的 IDE 用于开发 odoo,现在 运行 使用开始 > 调试 (F5)
当 运行在网络浏览器中 localhost:8069(默认)然后出现 内部服务器错误并且在终端VSCode中有错误:
Traceback (most recent call last):
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/registry.py", line 63, in __new__
return cls.registries[db_name]
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/tools/func.py", line 71, in wrapper
return func(self, *args, **kwargs)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/tools/lru.py", line 34, in __getitem__
a = self.d[obj]
KeyError: 'usu02' #this my database name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/teguhteja/P/OdooProject/odoo1/.venv/lib/python3.7/site-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/home/teguhteja/P/OdooProject/odoo1/.venv/lib/python3.7/site-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/service/server.py", line 441, in app
return self.app(e, s)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/service/wsgi_server.py", line 113, in application
return application_unproxied(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/service/wsgi_server.py", line 88, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/http.py", line 1306, in __call__
return self.dispatch(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/http.py", line 1272, in __call__
return self.app(environ, start_wrapped)
File "/home/teguhteja/P/OdooProject/odoo1/.venv/lib/python3.7/site-packages/werkzeug/middleware/shared_data.py", line 260, in __call__
return self.app(environ, start_response)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/http.py", line 1461, in dispatch
odoo.registry(db).check_signaling()
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/__init__.py", line 104, in registry
return modules.registry.Registry(database_name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/registry.py", line 65, in __new__
return cls.new(db_name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/loading.py", line 457, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/loading.py", line 349, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/loading.py", line 179, in load_module_graph
load_openerp_module(package.name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/modules/module.py", line 385, in load_openerp_module
__import__('odoo.addons.' + module_name)
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/addons/base_vat/__init__.py", line 4, in <module>
from . import models
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/addons/base_vat/models/__init__.py", line 6, in <module>
from . import res_partner
File "/home/teguhteja/P/OdooProject/odoo1/odoo-14.0/odoo/addons/base_vat/models/res_partner.py", line 7, in <module>
import stdnum
ModuleNotFoundError: No module named 'stdnum' - - -
我尝试搜索并在此处找到
- How to fix "ModuleNotFoundError: No module named 'python-stdnum'"
- UnicodeDecodeError: 'charmap' codec| Error during installation of pip python-stdnum==1.8
然后
pip install python-stdnum == 1.17 # new version
但结果是一样的。然后我查看我的 pip 列表
pip list
appdirs 1.4.4
attrs 21.2.0
Babel 2.6.0
backcall 0.2.0
bcrypt 3.2.0
beautifulsoup4 4.10.0
cached-property 1.5.2
certifi 2021.10.8
cffi 1.15.0
chardet 3.0.4
decorator 4.3.0
defusedxml 0.7.1
docutils 0.14
ebaysdk 2.1.5
freezegun 0.3.11
future 0.18.2
gevent 1.5.0
greenlet 0.4.15
html2text 2018.1.9
idna 2.6
ipdb 0.13.9
ipython 7.30.1
isodate 0.6.0
jedi 0.18.1
Jinja2 2.10.1
libsass 0.17.0
lxml 4.3.2
Mako 1.0.7
MarkupSafe 1.1.0
matplotlib-inline 0.1.3
num2words 0.5.6
ofxparse 0.19
parso 0.8.3
passlib 1.7.1
pexpect 4.8.0
pickleshare 0.7.5
Pillow 5.4.1
pip 21.3.1
polib 1.1.0
prompt-toolkit 3.0.24
psutil 5.8.0
psycopg2 2.7.7
ptyprocess 0.7.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pydot 1.4.1
Pygments 2.10.0
pyodbc 4.0.32
pyparsing 3.0.6
PyPDF2 1.26.0
pyserial 3.4
python-dateutil 2.7.3
python-ldap 3.1.0
python-stdnum 1.17
pytz 2019.1
pyusb 1.0.2
pyzk 0.9
qrcode 6.1
reportlab 3.5.13
requests 2.21.0
requests-toolbelt 0.9.1
setuptools 41.2.0
six 1.16.0
soupsieve 2.3.1
toml 0.10.2
traitlets 5.1.1
urllib3 1.24.3
vobject 0.9.6.1
wcwidth 0.2.5
Werkzeug 0.16.1
wheel 0.37.0
xlrd 1.1.0
XlsxWriter 1.1.2
xlwt 1.3.0
我发现我的 python-stdnum 已经安装
我怀疑我的问题在 launch.json vscode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Odoo",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"python": "${command:python.interpreterPath}",
// "console": "externalTerminal",
"program": "${workspaceRoot}/odoo-14.0/odoo-server",
"args": [
"--config=${workspaceRoot}/conf/odoo-training14.conf",
],
"cwd": "${workspaceRoot}",
// "env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"RedirectOutput"
]
}
]
}
如何解决我的问题?
备选方案 目前我 运行 odoo 使用下面的命令并使用 ipdb
进行调试python3 odoo-14.0/odoo-server -c conf/odoo-training14.conf
尝试了几天后才发现项目中的 pip 和 python 由于更新而没有指向 .venv 而是指向 anaconda。当错误
no module stdnum
实际上 pip 有问题所以请确保你的 pip 路径为 which pip 或 which python
- 通过删除 .venv 文件夹解决 .venv 不起作用的问题,在 python 中创建 venv,然后重新安装所有要求
rm .venv
python3 -m venv .venv
source .venv/bin/activate.fish
python3 -m pip install --upgrade pip # upgrade pip
pip install -r requirements.txt
- 因为它使用 vscode 确保你的解释器 ctrl + shift + P 然后
Python : Select Interpreter
并选择您的 .venv
之后就可以正常调试了