创建python包后无法调用函数

问题描述

最近我创建了我的第一个名为 pycohort 的包:https://pypi.org/project/pycohort/

这里有现有的 python 函数,它们可以正常工作,没有任何问题。代码片段如下所示:

# packages needed
import pandas as pd
import numpy as np

def calculate_mean(some_list):

    """Function to calculate the mean of the data set.
    Returns: 
        float: mean of the data set
    """

    return (1.0 * sum(some_list) / len(some_list))

我先pip install pycohort,然后是import pycohort。当我像 pycohort.calculate_mean(df.col1) 这样调用上述函数时,我收到错误消息:AttributeError: module 'pycohort' has no attribute 'calculate_mean'

上传函数时,我导航到我当前的工作目录,然后输入以下代码。但是我不怀疑这里有问题,因为我能够成功上传和pip安装。

python setup.py sdist
pip install twine
twine upload dist/*

关于上传调用函数,我在这里遗漏了什么?

感谢您的帮助,

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)