6

Relatively new to Python I've created a project using Pipenv that uses the xmltodict module. I've looked at some similar questions but can't find exactly what I need to do.

I've used pipenv to install the xmltodict module but I'm still getting the following error:

Traceback (most recent call last):
  File "./storagereport.py", line 12, in <module>
    import xmltodict
ImportError: No module named 'xmltodict'

Pipenv shows that the module is installed:

$ pipenv graph
xmltodict==0.12.0

Can anyone help?

MattB
  • 135
  • 1
  • 3
  • 10

4 Answers4

4

Try with following command:

sudo pip install xmltodict

or

sudo pip install xmltodict --upgrade
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
3

You might be running Python from another version , which is usually the default version that is installed. If that's the case, in your virtual environment you will find python.exe and pip.exe you have to run pip from the virtual environment

Amine Messaoudi
  • 2,141
  • 2
  • 20
  • 37
  • I'm running the pip/pip3 and python3 ./storageport.py within the pipenv shell, is that what you mean? – MattB May 01 '19 at 08:12
0

I run into this regularly, I believe because I'm behind a firewall. I download the package that I need to my computer and then I install it. If that doesn't work, I navigate to the download folder where it is and install it from there. You can download this package here:

https://pypi.org/project/xmltodict/

mauve
  • 2,707
  • 1
  • 20
  • 34
  • In the question it is confirmed that the module is installed: "Pipenv shows that the module is installed" why dou you assume that it is not? – FlyingTeller Apr 30 '19 at 14:51
  • Hmm I can't seem to reply with the full command output, I'll edit the original – MattB Apr 30 '19 at 14:54
0

I downloaded the file from here- https://pypi.org/project/xmltodict/#files and after extraction placed the .py file in the directory where I was importing xmltodict. Then it worked fine.

sauravjoshi23
  • 837
  • 11
  • 9