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

6 comments

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.

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

---

Original message URL:

http://devnet.jetbrains.net/message/5268992#5268992

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

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

0

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? =(

0

Hello Aleksandr,

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? =(

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!"

0

So,

I have following paths currently:

paths.jpg

As you see - two of them I added manually.

Here is content of those folders:

MacBook-Aleksandr-Motsjonov:~ soswow$ cd /Library/Python/2.6/site-packages/matplotlib-1.0.0-py2.6-macosx-10.6-universal.egg/

MacBook-Aleksandr-Motsjonov:matplotlib-1.0.0-py2.6-macosx-10.6-universal.egg soswow$ ls

EGG-INFO     matplotlib   mpl_toolkits pylab.py     pylab.pyc

And now, when I add this to some empty python file:

import matplotlib

print "Import is ok"

I see unresolved reference:

unresolved.jpg

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
0

Hello Aleksandr,

This one is a known problem:

http://youtrack.jetbrains.net/issue/PY-3085

So,

I have following paths currently:

Image:paths.jpg

As you see - two of them I added manually.

Here is content of those folders:

MacBook-Aleksandr-Motsjonov:~ soswow$ cd
> /Library/Python/2.6/site-packages/matplotlib-1.0.0-py2.6-macosx-10.6-u
> niversal.egg/
> 
> MacBook-Aleksandr-Motsjonov:matplotlib-1.0.0-py2.6-macosx-10.6-univers
> al.egg soswow$ ls
> 
> EGG-INFO     matplotlib   mpl_toolkits pylab.py     pylab.pyc

And now, when I add this to some empty python file:

import matplotlib print
> "Import is ok"

I see unresolved reference:

Image:unresolved.jpg

But when I run it, I get "Import is ok" printed.

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Please sign in to leave a comment.