Matt W.
Matt W.

Reputation: 3722

updates from updated py file not working when imported

I have a python file with various functions, called mypyfile. For a while now I have had custom functions there that I use, and I import them in using import mypyfile. I recently moved to 3.6 from 3.4 because of dependencies from a specific package I was using. I am now trying to import mypyfile, but the update that I made to the file and saved it, is not working.

The mypyfile.py exists in the main working directory. The import function does work, and it does import my file in. When I use the newly changed function from that file is when it fails, indicating that the changes I made were not updated.

I'm likely not doing the package thing right in python, I just have a .py file with functions in it, no init.py file, or structured package folder. just one .py file with a bunch of functions in it.

Upvotes: 2

Views: 4001

Answers (1)

ash
ash

Reputation: 5529

It's possible that Python is using a cached bytecode version of your file, rather than reading the new version. If you have a __pycache__ directory, or any files with the extension .pyc, try deleting them and importing your file again.

Upvotes: 4

Related Questions