When I debug some code in PyCharm I encounter a module not found error, even though the package is installed and the import is valid:
from azure.storage.blob.blockblobservice import BlockBlobService
ModuleNotFoundError: No module named 'azure.storage'
The above does not happen when I launch the code from PyCharm (i.e. Run instead of Debug), so my initial suspicion is that this is something particular to the debugger. The azure-storage
package is the only one I've seen to cause this trouble so it may be that the packaging is somehow goobered and causing the problem. (I suspect this because I'm not the first to experience something like this.)
I can successfully run the above import command in PyCharm's Python Console, as well as when using vanilla Python within a terminal window (i.e. this issue seems to be specific to only the PyCharm debugger).
I have installed azure-storage via PyPI into the Anaconda virtual environment used by the PyCharm project. I can see the package(s) when I list the installed packages:
$ conda list | grep azure
azure-common 1.1.16 <pip>
azure-storage-blob 1.3.1 <pip>
azure-storage-common 1.3.0 <pip>
azure-storage-nspkg 3.0.0 <pip>
What's interesting is that none of the azure packages show up in the listing of installed packages for the project's interpreter in PyCharm. So in a sense, the packages aren't found by PyCharm, even though they're clearly installed in the Anaconda virtual environment being used as the interpreter for the project.
I have installed and reinstalled azure-storage
a number of ways suggested in other SO posts and GitHub issue comments, and finally going with the PyPI installation described on the main project page has led to no better results.
I am seeing this behavior on Ubuntu 18.04, the Python version is 3.6.
What may be causing this issue, or is there a way around it?
It turns out that the issue here was that I had a source folder in my project named azure
. Once I renamed that to something else this problem went away. The azure-storage-*
packages still don't appear in the list of installed packages for the project's interpreter in PyCharm, but that's an idiosyncrasy I can live with for now.