Python Interpeter Paths
Hello,
I'm relatively new to python and pycharm, so forgive me if this is an obvious question, but:
1) I installed python3.1 on my mac and added it as an interpreter to pycharm.
2) I added a library of mine to the paths for the selected 3.1 interpreter.
3) In my project directory, the library shows up under external libraries and I can click through on the imports and usages.
BUT
I get an error when running or debugging a script because the imported library could not be found.
Is that expected behavior? What else do I need to do to get my library into my project paths?
Thanks!
Gus
Please sign in to leave a comment.
Hello Gus,
You need to define the PYTHONPATH environment variable in the run configuration
and specify the path to your library. The interpreter configuration in PyCharm
only affects the development-time functionality, such as navigation and code
completion.
Note that Python libraries are typically installed under the site-packages
directory of the Python installation, and such libraries are loaded by Python
automatically, without any additional configuration in PyCharm.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Great! That got my going.
This is probably an actual bug, but:
If you edit the default python environment variables and apply/save. You have to restart pycharm before new python configurations will pick up the default.
Best,
Gus
It seems, that I have opposite situation: When I add something to "paths" in PyCharm settings, see it in my sys.path list, and code, that uses those paths compiles, but pycharm environment don't see it (auto-competition).
What can I do? =(
Hello Aleksandr,
You can provide more details and the steps to reproduce. Let's start with:
is it a binary module or a Python library?
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
So,
I have following paths currently:
As you see - two of them I added manually.
Here is content of those folders:
And now, when I add this to some empty python file:
I see unresolved reference:
But when I run it, I get "Import is ok" printed.
p.s.
Interesting, why do I can make code listing with syntax highlighting for Html, SQL, Java, but not Python, which seems odd on Python IDE forum. :-P
Attachment(s):
paths.jpg
unresolved.jpg
Hello Aleksandr,
This one is a known problem:
http://youtrack.jetbrains.net/issue/PY-3085
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"