2

A python newbie question:

On an Ubuntu system, I installed a python package using sudo pip install. (The package is called hlmm)

I'm using the miniconda3 environment and the only environment variable specified in my .bashrc is:

export PATH="/home/<my_username>/miniconda3/bin:$PATH"

Now I want to run a test script from the package I installed, which is located under a tests folder relative to where that package was installed.

I used pip list | xargs -exec pip show to look for the location of that package but it doesn't show up.

I also tried in python to import the package, using:

import hlmm

And I'm getting:

>>> import hlmm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'hlmm'

If I redo sudo pip install hlmm I get:

Requirement already satisfied: hlmm in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: pysnptools in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: pandas>=0.19.0 in /usr/local/lib/python2.7/dist-packages (from pysnptools->hlmm)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python2.7/dist-packages (from pandas>=0.19.0->pysnptools->hlmm)
Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python2.7/dist-packages (from pandas>=0.19.0->pysnptools->hlmm)
Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/dist-packages (from python-dateutil>=2.5.0->pandas>=0.19.0->pysnptools->hlmm)

And, I do see the hlmm folder under /usr/local/lib/python2.7/dist-packages, but cannot find that tests folder:

ls -1 /usr/local/lib/python2.7/dist-packages/hlmm
__init__.py
__init__.pyc
hetlm.py
hetlm.pyc
hetlmm.py
hetlmm.pyc

How do I find its location? And, is the package really successfully installed despite the import hlmm error?

dan
  • 6,048
  • 10
  • 57
  • 125
  • 1
    Possible duplicate of [Anaconda site-packages](https://stackoverflow.com/questions/31003994/anaconda-site-packages) – Mason Caiby Sep 25 '19 at 00:37
  • This link does not solve my problem. I edited my question accordingly. – dan Sep 25 '19 at 00:49
  • 1
    An issue can be that you are not searching the miniconda environment, but a pre-installed `python2.7` version. If, in the interpreter that shows `no module named hlmm` you type `import sys print(sys.version)` do you get `2.7`? Have you activated the miniconda environment that you install `hlmm` into? – Mason Caiby Sep 25 '19 at 01:32
  • Thanks @Mason Caiby. Yes, I activated my `miniconda` environment (`source activate /home//miniconda3`) before trying to import the package. `print(sys.version)` returns: `3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) [GCC 7.2.0]` – dan Sep 25 '19 at 01:40
  • 1
    is `hlmm` included in the packages shown with `conda list` after activating your package? – Mason Caiby Sep 25 '19 at 04:33
  • No, it doesn't show up. Is it possible that the `sudo pip install hlmm` I ran to install it (after activating my `miniconda` environment) is at fault and I should have installed it differently? – dan Sep 25 '19 at 04:59

1 Answers1

1

This was getting too long to be a comment, so I'm posting it as an answer.

Yeah, it sounds like pip installed it from your python 2.7 version. You should read this post: How to install PyPi packages using anacaonda conda command and this article: https://www.anaconda.com/using-pip-in-a-conda-environment/ to decide how you want to proceed. I generally use conda when possible, and pip if conda doesn't have a build. You might want to run pip uninstall hlmm then activate your conda env and use pip3 install hlmm. But, I think you should decide the best way to manage your environments after doing research.

Mason Caiby
  • 1,846
  • 6
  • 17
  • This might not solve your problem, using conda after you have installed things with python (or even sometimes when you have 2 python versions installed) can be a huge pain. Let me know if it works or not. – Mason Caiby Sep 25 '19 at 05:11