Talha Farid
Talha Farid

Reputation: 23

Importing python file into my pycharm that is in the same directory

Im trying to import a python file into my pycharm program.

The file is in the exact same folder as my pycharm project is. I tried to use :

open("happy_histogram.py","r",encoding="utf-8")

but it fails to work.

Appreciate your help!

Upvotes: 1

Views: 301

Answers (1)

ayc.19
ayc.19

Reputation: 98

What are you importing the file for? If you're trying to use some functions and other variables in happy_histogram.py you maybe be better importing it using

from happy_histogram import *

But to make your code work, I was able to open a file by taking out the encoding. open("happy_histogram.py", "r") hope that helps.

Upvotes: 1

Related Questions