Problems with pip install and PYTHONPATH

0 views
Skip to first unread message

Christian Vorwerk

unread,
Nov 29, 2016, 3:44:51 AM11/29/16
to conda - Public
Hi all,
the topic of a set pythonpath is quite frequent here, but I couldn't find an answer to my specific problem:

1. I have PYTHONPATH directed towards a local module on my machine.

2. I use pip install -e within a conda environment to install a module obtained from git. I have made sure that pip is installed
    in the environment and that I use the correct pip version.

3. After the install, the iinstalled module is available in all other environments.

The only way to resolve this that I have found is to unset the PYTHONPATH, but the module it points to and the one I am installing
in the environment are completely independent.

Is this a feature of conda or a bug? How do I keep a fixed PYTHONPATH and still remain able to use pip install in an environment?

Thanks for your help,

Christian Vorwerk

Ilan Schnell

unread,
Nov 29, 2016, 4:10:20 AM11/29/16
to Christian Vorwerk, conda - Public
Hi Christian,

the problem is probably that PYTHONPATH is pointing to a directory which contains modules which conflict with modules used by pip or conda.  Generally, it is not a good idea to set PYTHONPATH.  I would recommend creating a '.pth' file in site-packages which points to the location where your module is located.  What is the content of the directory PYTHONPATH is pointing to?
$ ls -l $PYTHONPATH

- Ilan

--
You received this message because you are subscribed to the Google Groups "conda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to conda+un...@continuum.io.
To post to this group, send email to co...@continuum.io.
Visit this group at https://groups.google.com/a/continuum.io/group/conda/.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/conda/9c2a6e9f-3498-45bb-bc14-06fabbab798e%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Christian Vorwerk

unread,
Nov 29, 2016, 4:25:23 AM11/29/16
to conda - Public, vorwerkc...@gmail.com
My .bashrc contained the line
export PYTHONPATH=$PYTHONPATH:/home/christian/Dokumente/bin/myModule/

and myModule contained two python files. The module has some dependencies, such as lxml, numpy, math and os.
Could that be the problem? The myModule is not connected to the one I tried to pip install.

Thanks for the tip with the *.pth file.

Christian

Ilan Schnell

unread,
Nov 29, 2016, 4:46:37 AM11/29/16
to Christian Vorwerk, conda - Public
The fact that the modules in 'myModule' import numpy or lxml is not a problem.  My question is what the names of these two modules are.  If those modules names conflict with other names (from the standard library or site-packages) which are imported in pip or conda then there is a problem.  What are the names of the two modules?

Thanks   Ilan

Christian Vorwerk

unread,
Nov 29, 2016, 5:17:02 AM11/29/16
to conda - Public, vorwerkc...@gmail.com

OK, now I get the question. The modules are called parsebands and parsedos. I don't think that there are already modules with these names.

Thanks for your help,

Christian

Ilan Schnell

unread,
Nov 29, 2016, 5:21:47 AM11/29/16
to Christian Vorwerk, conda - Public
No, I don't think those names are already in use either.  In my Anaconda installation, I get import errors for those names.  So in that case setting PYTHONPATH should in principle work, but I would still recommend adding a '.pth' file in site-packages instead.


Christian Vorwerk

unread,
Nov 29, 2016, 5:23:43 AM11/29/16
to conda - Public, vorwerkc...@gmail.com
Yes, I tried using the .pth file already and it works much better, since I can add it in the site-packages of a specific environment, which makes more sense than setting a global pythonpath.
Thanks for your quick help!

Christian

Chris Barker - NOAA Federal

unread,
Nov 29, 2016, 10:47:03 AM11/29/16
to Christian Vorwerk, conda - Public


Yes, I tried using the .pth file already and it works much better, since I can add it in the site-packages of a specific environment, which makes more sense than setting a global pythonpath.

Even better would be to make your modules a package and install them with "develop" or "editable" mode.

CHB


Reply all
Reply to author
Forward
0 new messages