问题:I希望在特定的conda环境中安装本地包。为此,我阅读了当前文档(python-打包)。
包结构:
$ pwd
~/…/test
.
|- requirements.txt
|- my_package
| |-- __init__.py
| |-- base.py
|- setup.pysetup.py
# -*- coding: utf-8 -*-
import os
from setuptools import setup
with open('requirements.txt') as f:
requirements = f.read().splitlines()
setup(
name='my_package',
version='2.0.0',
author='B.Gees',
author_email='B.Gees@gmail.com',
license='MIT',
packages=['my_package'],
description='my package description',
long_description='my package long description',
keywords='chemistry machine learning cheminformatics',
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Healthcare Industry',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.5.5',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Pharmacokinetic',
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=requirements,
zip_safe=False
)requirements.txt
pandas==0.19.2
dill==0.2.7.1
cython==0.23.4__init__.py
# -*- coding: UTF-8 -*-
"""
my_package
~~~~~~~~~~
my package full description
:copyright: (c) 2018 by B.Gees.
:license: MIT, see LICENSE file for more details.
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import logging
__title__ = 'my_package'
__version__ = '2.0.0'
__author__ = 'B.Gees'
__email__ = 'B.Gees@gmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2018 B.Gees'
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())base.py
# -*- coding: UTF-8 -*-
def titi(x):
return x**2我在一个特定的conda环境中安装了我的软件包,代码行如下:
conda activate my_env
pip install . # In my package repository然而,当我试图在jupyter笔记本中导入my_package时,我会得到以下错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-9-daa52839320b> in <module>()
----> 1 import my_package
ImportError: No module named 'my_package'当我使用python pip外部conda环境时,这个安装工作得很好。
问题:我不知道如何在特定的conda环境中正确安装我的软件包。我需要你的灯来启发我。
配置:带有MacOSX和python3.5的conda3;需要与Linux 7兼容
发布于 2018-10-30 10:11:05
您正在使用MacOSX,所以您应该首先使用source activate yourenvname,然后您可以使用您所做的来安装您的软件包。有关更多信息,如何激活Anaconda环境
首先是:conda create --name my_env python=3.5,然后是source activate my_env
https://stackoverflow.com/questions/53061516
复制相似问题