Mumtaz Begum C
Mumtaz Begum C

Reputation: 109

Not recognizing the import module in Django application

 File "C:\Users\User\projects\Datascience\Bee_Word_Project\spellbee\views.py", line 4, in <module>
    from . import beewordpick 
  File "C:\Users\User\projects\Datascience\Bee_Word_Project\spellbee\beewordpick.py", line 4, in <module>
    import pyttsx3
ModuleNotFoundError: No module named 'pyttsx3'

Actually, the above pyttsx3 module is pip installed. Django not identifying env PATH in their search list. It searches the module in the local application path only.

Can anyone recommend how to set up a search for the import modules in Django? what has to be done at settings.py? when I run the same module using the FLASK application, I can able to run that application.

(test) PS C:\Users\User\projects\Datascience\Bee_Word_Project> pip freeze
   asgiref==3.2.10
   Django==3.1.2
   pytz==2020.1
   sqlparse==0.3.1

If I add that library into my above working path, it can able to recognize, But it is not picking from sys env PATH library as this module is python package After adding to local environment, it worked fine. But today , all of sudden , it is not working due to the module inside the pyttsx3 - driver ModuleNotFoundError at /spellbee/ No module named 'comtypes' Request Method: POST Request URL: http://xxxxxxx/spellbee/ Django Version: 3.1.2 Exception Type: ModuleNotFoundError Exception Value:
No module named 'comtypes' Exception Location: C:\Users\User\projects\Datascience\Bee_Word_Project\pyttsx3\drivers\sapi5.py, line 1, in Python Executable: C:\Users\User\Envs\test\Scripts\python.exe Python Version: 3.8.5 Python Path:
['C:\Users\User\projects\Datascience\Bee_Word_Project', 'C:\Users\User\Envs\test\Scripts\python38.zip', 'c:\users\user\appdata\local\programs\python\python38-32\DLLs', 'c:\users\user\appdata\local\programs\python\python38-32\lib', 'c:\users\user\appdata\local\programs\python\python38-32', 'C:\Users\User\Envs\test', 'C:\Users\User\Envs\test\lib\site-packages']

Upvotes: 0

Views: 1440

Answers (1)

FazelSamar
FazelSamar

Reputation: 46

... Django not identifying env PATH in their search list ...

I think you missing small things. Django has nothing to do with env, It's all about where django runs. If you run django in environment, them it use env pip modules, if it runs in local, it use local pip modules

Now in your (test) environment, pyttsx3 doesn't installed in pip lists

Try pip install pyttsx3 in both env and local, then test that out

And sometimes you need to add the modules in installed apps:

INSTALLED_APPS = [
...
'pyttsx3',
...
]

Upvotes: 1

Related Questions