找到conda放置我安装的python包的位置

时间:2019-09-25 00:32:34

标签: python ubuntu miniconda

一个python新手问题:

Ubuntu系统上,我使用python安装了sudo pip install软件包。 (该程序包称为hlmm

我正在使用miniconda3环境,在我的environment variable中指定的唯一.bashrc是:

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

现在,我想从安装的程序包中运行测试脚本,该程序包相对于该程序包的安装位置位于tests文件夹下。

我使用pip list | xargs -exec pip show查找该包裹的位置,但没有显示。

我也在python中尝试使用以下方式导入包:

import hlmm

我得到了:

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

如果我重做sudo pip install hlmm,我会得到:

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)

而且,我确实看到了hlmm下的/usr/local/lib/python2.7/dist-packages文件夹,但是找不到该tests文件夹:

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

我如何找到它的位置?而且,尽管出现了import hlmm错误,该软件包真的能成功安装吗?

1 个答案:

答案 0 :(得分:1)

这太久了,无法发表评论,所以我将其发布为答案。

是的,听起来pip是从python 2.7版本安装的。您应该阅读这篇文章:How to install PyPi packages using anacaonda conda command和本文:https://www.anaconda.com/using-pip-in-a-conda-environment/,以决定要如何进行。如果可能,我通常使用conda,如果conda没有构建,则通常使用pip。您可能需要运行pip uninstall hlmm,然后激活conda env并使用pip3 install hlmm。但是,我认为您应该在进行研究后决定管理环境的最佳方法。