`No module named 'X'`

It seems that external dependencies aren't being indexed correctly in my PyCharm

for example `pandas` and `torch` will trigger the `No module named` inspection, but none of the others will

import argparse
import json
import os
import pickle
import sys
import pandas as pd
import torch

However, they are installed in my `virtualenv` environment


Comment actions Permalink

Have you tried File | Invalidate Caches/Restart... | Invalidate and Restart?

What PyCharm version do you use?

Comment actions Permalink

Thank you Sergey

> Have you tried File | Invalidate Caches/Restart... | Invalidate and Restart?


> What PyCharm version do you use?

PyCharm 2020.1.3 (Professional Edition)
Build #PY-201.8538.36, built on July 7, 2020
Licensed to Ian Edington
Subscription is active until July 31, 2020
Runtime version: 11.0.7+10-b765.64 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.6
GC: ParNew, ConcurrentMarkSweep

Non-Bundled Plugins: IdeaVIM, String Manipulation, org.toml.lang
Comment actions Permalink

How did you create this virtual environment?
Does the same problem appear with a virtualenv created by PyCharm? https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html

Comment actions Permalink

Thanks Sergey,

I used pipenv to create the environment. The pipenv tool in PyCharm assumes you want PyCharm to create the environment, so instead I used the virtual environment that pipenv uses under the hood as the Python Interpreter.

I would prefer not to create the virtual env in that way since I use pipenv. The pipenv with PyCharm doesn't work for my use case because it throws an error since the environment is already created.

Is there any other information I could share with you that would be useful for debugging this issue?


Please sign in to leave a comment.