ModuleNotFoundError: No module named 'erpnext' centos7

this error on centos7 comes after commands :

[benchs@localhost ~]$ bench init erpnext
.
.
.
SUCCESS: Bench erpnext initialized
[benchs@localh…ost ~]$ cd erpnext
[benchs@localhost erpnext]$ bench new-site erp.example.com

[benchs@localhost erpnext]$ bench get-app erpnext GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: pip install frappe-bench

Getting erpnext
.
.
.
/tmp/pip-wheel-2uzujohm
cwd: /tmp/pip-install-6wy7ye_c/jsonobject_ac80d70828024bb6b6236710db72ab42/
Complete output (21 lines):
You are running without Cython installed. It is highly recommended to run
pip install cython>=0.29.21,<1.0.0
before you continue
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/jsonobject
copying jsonobject/init.py → build/lib.linux-x86_64-3.6/jsonobject
copying jsonobject/exceptions.py → build/lib.linux-x86_64-3.6/jsonobject
running build_ext
building ‘jsonobject.api’ extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/jsonobject
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/benchs/erpnext/env/include -I/usr/include/python3.6m -c jsonobject/api.c -o build/temp.linux-x86_64-3.6/jsonobject/api.o
jsonobject/api.c:16:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
error: command ‘gcc’ failed with exit status 1

ERROR: Failed building wheel for jsonobject
ERROR: Command errored out with exit status 1:
command: /opt/benchs/erpnext/env/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-6wy7ye_c/jsonobject_ac80d70828024bb6b6236710db72ab42/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-6wy7ye_c/jsonobject_ac80d70828024bb6b6236710db72ab42/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’“‘))’ install --record /tmp/pip-record-hq23bpf8/install-record.txt --single-version-externally-managed --compile --install-headers /opt/benchs/erpnext/env/include/site/python3.6/jsonobject
cwd: /tmp/pip-install-6wy7ye_c/jsonobject_ac80d70828024bb6b6236710db72ab42/
Complete output (21 lines):
You are running without Cython installed. It is highly recommended to run
pip install cython>=0.29.21,<1.0.0
before you continue
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/jsonobject
copying jsonobject/init.py → build/lib.linux-x86_64-3.6/jsonobject
copying jsonobject/exceptions.py → build/lib.linux-x86_64-3.6/jsonobject
running build_ext
building ‘jsonobject.api’ extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/jsonobject
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/benchs/erpnext/env/include -I/usr/include/python3.6m -c jsonobject/api.c -o build/temp.linux-x86_64-3.6/jsonobject/api.o
jsonobject/api.c:16:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
error: command ‘gcc’ failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/benchs/erpnext/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '”‘"’/tmp/pip-install-6wy7ye_c/jsonobject_ac80d70828024bb6b6236710db72ab42/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-6wy7ye_c/jsonobject_ac80d70828024bb6b6236710db72ab42/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-hq23bpf8/install-record.txt --single-version-externally-managed --compile --install-headers /opt/benchs/erpnext/env/include/site/python3.6/jsonobject Check the logs for full command output.
WARNING: You are using pip version 21.1.2; however, version 21.1.3 is available.
You should consider upgrading via the ‘/opt/benchs/erpnext/env/bin/python -m pip install --upgrade pip’ command.
$ yarn install
yarn install v1.22.5
[1/4] Resolving packages…
[2/4] Fetching packages…
[3/4] Linking dependencies…
warning Workspaces can only be enabled in private projects.
[4/4] Building fresh packages…
$ yarn run snyk-protect
yarn run v1.22.5
$ snyk protect
Successfully applied Snyk patches

Done in 27.59s.
Done in 100.68s.
$ bench build --app erpnext
WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: pip install frappe-bench

Traceback (most recent call last):
File “/opt/benchs/erpnext/apps/frappe/frappe/utils/bench_helper.py”, line 70, in get_app_commands
app_command_module = importlib.import_module(app + ‘.commands’)
File “/usr/lib64/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 941, in _find_and_load_unlocked
File “”, line 219, in _call_with_frames_removed
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘erpnext’
Traceback (most recent call last):
File “/usr/lib64/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib64/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/opt/benchs/erpnext/apps/frappe/frappe/utils/bench_helper.py”, line 104, in
main()
File “/opt/benchs/erpnext/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/opt/benchs/erpnext/env/lib/python3.6/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/opt/benchs/erpnext/env/lib/python3.6/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/opt/benchs/erpnext/env/lib/python3.6/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/opt/benchs/erpnext/env/lib/python3.6/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/opt/benchs/erpnext/env/lib/python3.6/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/opt/benchs/erpnext/env/lib/python3.6/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/opt/benchs/erpnext/apps/frappe/frappe/commands/utils.py”, line 29, in build
frappe.init(‘’)
File “/opt/benchs/erpnext/apps/frappe/frappe/init.py”, line 206, in init
setup_module_map()
File “/opt/benchs/erpnext/apps/frappe/frappe/init.py”, line 1115, in setup_module_map
for module in get_module_list(app):
File “/opt/benchs/erpnext/apps/frappe/frappe/init.py”, line 983, in get_module_list
return get_file_items(os.path.join(os.path.dirname(get_module(app_name).file), “modules.txt”))
File “/opt/benchs/erpnext/apps/frappe/frappe/init.py”, line 941, in get_module
return importlib.import_module(modulename)
File “/usr/lib64/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘erpnext’

I find that running sudo apt-get install python3.X-dev where X is your python sub-version usually resolves such issues

Cheers

2 Likes