Importing a package

I am unable to import speech_recognition package (which I already installed) into my views.py file. Can someone please help me out with this?

We’ll need to know a bit more about your environment.

Are you running Django in a virtual environment?

Did you install this package in that virtual environment?

What happens if you run the Django shell (python manage.py shell) and then try to import the package?

What happens if you run the Python shell and try to import the package?

When you try to import it in your view, what error message do you receive? Do you get the ModuleNotFound error or something else?

What operating system are you using? What version of Python?

I am using python 3.7.4 on Mac OS. I have set up the virtual environment and have also put the package inside the root directory where my virtual environment as well as my project exist. I have solved the problem for speech_recognition but am now facing the same difficulties with the PIL package.

It may just be an issue of terminology here, but to be clear, you don’t just “put” packages in your virtual environment, nor should your code reside within the virtual environment directory structure.

Packages get installed into a virtual environment using pip, and your project should be in a completely separate directory. (You then “activate” the virtual environment to run your project.)

Yeah I now tried installing it after activating the virtual environment and it did work! Thank you for your guidance! :slightly_smiling_face: