0
votes

Within my project XYZ, I have a file superSource.py, which contains some functions.

Now, I've used the new cool pyCharm feature of creating an IPython notebook, which I calltest test.ipynb, and saved it in the projects main directory (next to superSource.py).

However, when I run import superSource; foo = superSource.parameters() nothing happens, I don't even get a warning. pyCharm will underline superSource within the code though, warning me that there is no module called superSource.

How can I include other files from the same directory using the IPython notebook and/or pyCharm?

1

1 Answers

1
votes

I've had the same problem and have a partial solution.

To include your file, add the following to a cell:

execfile("superSource.py").

This should load and execute it and make its contents available for reuse so that you can access variable and call functions defined or imported by it in other cells.

Unfortunately, PyCharm does not know about it, so that as you type, there is no statement completion and if you have "Show import popup" enabled in PyCharm, it will suggest adding an import but highlight it as an error afterwards. It should still work, however.