in python console it imports module with no errors.
Is that the Python console on your local machine or server? If server, what path are you using to run the Python console? What version of ArcGIS Server and what version of Linux?
Maybe it'll help:
we also needed a additional custom Python package. As we only have access to our Linux server via shell, we installed the missing module via "/<ArcGISServer_InstallDir>/server/tools/python -m pip install <modulname>". The package was insalled into /<ArcGISServer_InstallDir>/server/framework/runtime/.wine/drive_c/Python27/ArcGISx6410.6/Lib/site-packages
Update: we finally copied the folder of the site package into: /<ArcGISServer_InstallDir>/server/framework/runtime/ArcGIS/bin/Python/envs/arcgispro-py3/Lib/site-packages. I don't know if this is the correct way to do, but now our geoprocessing service can use the custom Python package.