Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm unresolved reference in virtualenv

When I started a new project in Pycharm using virtual environment, I got an unresolved reference warning message.

enter image description here

But I have installed django to my virtual environment and this code is working correctly.

How can I fix this? I'm using PyCharm 4.5.2 Pro

like image 233
Dima Kudosh Avatar asked Aug 21 '15 16:08

Dima Kudosh


2 Answers

I think your problem is like mine. I tested import matplotlib in the python shell, and it works, but in Pycharm it shows an error. This is because Pycharm doesn't know the path of site-packages.

To fix this, you can do one of the following:

  • Add the path of site-packages (for me C:\Program Files\Python 3.5\lib\site-packages) to PATH.

  • Go to File -> Settings -> Project Interpreter, then choose Python real path instead of venu path. enter image description here

  • In your code add the following:

.

import sys    
sys.path.append(r"C:\Program Files\Python 3.5\lib\site-packages")
import matplotlib.pyplot as plt

I think it will help you :)

like image 155
Blue Phoenix Avatar answered Oct 18 '22 13:10

Blue Phoenix


Open your project in pycharm and follow the step:

click on file(on top) > settings > project interpreter > add local > select virtualenv

                      OR

Make sure your project is a root directory, make it is the root directory.

like image 23
Razia Khan Avatar answered Oct 18 '22 15:10

Razia Khan