python XGBoost module import failed after installation

I have installed XGBoost library using pip which is accessible in the python command prompt as shown below:

(base) abhishek@abhishek:~$ pip3 install xgboost
Collecting xgboost
  Using cached xgboost-1.2.1-py3-none-manylinux2010_x86_64.whl (148.9 MB)
Requirement already satisfied: scipy in ./anaconda3/lib/python3.7/site-packages (from xgboost) (1.5.0)
Requirement already satisfied: numpy in ./anaconda3/lib/python3.7/site-packages (from xgboost) (1.18.5)
Installing collected packages: xgboost
Successfully installed xgboost-1.2.1
(base) abhishek@abhishek:~$ python3
Python 3.7.7 (default, May  7 2020, 21:25:33) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xgboost
>>> 

However when I try to run a python file then python there is not able to find installed XGBoost module.

(base) abhishek@abhishek:~$ sudo python3 Downloads/ML_Case_Study/Solution/src/app_service.py 
Traceback (most recent call last):
  File "Downloads/ML_Case_Study/Solution/src/app_service.py", line 2, in <module>
    import xgboost as xgb
ModuleNotFoundError: No module named 'xgboost'

Any pointer to what might be root cause of this will help.