0

I'm trying to use chardet package in python, on Visual Studio 2017 15.6.2

Even when I have the chardet package installed, it is not recognized.

What could possibly be wrong?

Here is a screen capture

https://i.stack.imgur.com/vtCB5.png

If I try to run I get this exception

ModuleNotFoundError
  Message=No module named 'chardet'
jonuko
  • 39
  • 1
  • 5
  • What I see is a screen capture of a complaint from your IDE. Do you get `ImportError` when you run the code? – BoarGules Apr 08 '18 at 21:27
  • @BoarGules At runtime I get an exception "ModuleNotFoundError: No module named 'chardet'" https://i.imgur.com/8CrYM8W.png – jonuko Apr 08 '18 at 21:32
  • Then the environment in which you installed `chardet` is different from the one in which you are running the code. It is not just possible, but surprisingly easy, to have two or more different Python interpreters installed. Python 2 vs. Python 3, 32-bit vs 64-bit are both potent sources of this confusion. Or have you perhaps named your program `chardet.py`? – BoarGules Apr 08 '18 at 21:38
  • @BoarGules isn't the first screenshot showing that I'm using Anaconda 5? How do I check it? – jonuko Apr 08 '18 at 21:48
  • Maybe it does indicate you're using Anaconda, but I don't, and it's not entirely reasonable that you expect everyone to be using the same toolset as you do. Your question isn't tagged [anaconda]. – BoarGules Apr 08 '18 at 21:53
  • @@BoarGules Oh, no. I should set Anaconda in the Solution Explorer window. – jonuko Apr 08 '18 at 21:57
  • @BoarGules This is the first time I use pyhton in VS, and I was thinking that I should select Anaconda on the menu in the first screenshot... Thanks for your help. Have a prize https://www.youtube.com/watch?v=GvyeP32_v7o&t=0s&index=4&list=PLutSi8951Qb0DmhB1K18nfxxE2c8Tf-Sf – jonuko Apr 08 '18 at 22:03

1 Answers1

0

As BoarGules commented, I was using the wrong environment. The package was installed on another environment.

I switched to Anaconda 5, where the package is installed, and now it works. I leave a screen capture on how to change to Anaconda.

https://i.stack.imgur.com/2WSAi.png

jonuko
  • 39
  • 1
  • 5