无法将csv文件上传到test.pypi.org [英] Could not upload csv file to test.pypi.org

查看:108
本文介绍了无法将csv文件上传到test.pypi.org的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个简单的python软件包上传到PypI.为了进行测试,我首先上传到 test.pypi.org .当我使用pip安装此软件包并使用它时,出现错误FileNotFoundError: [Errno 2] File b'../data/spam_collection.csv' does not exist: b'../data/spam_collection.csv'. 我在StackOverflow和文档 此处.我已经尝试了很多,因为您可以看到这是我的软件包的版本11.我在这里做错了什么?

I am trying to upload a simple python package to PypI. For testing this I first uploaded to test.pypi.org. When I install this package with pip and use it, I get the error FileNotFoundError: [Errno 2] File b'../data/spam_collection.csv' does not exist: b'../data/spam_collection.csv'. I implemented the following referring to other similar questions on StackOverflow and the documentation here and here. I tried with this a lot as you can see this is the version 11 of my package. What am I doing wrong here?

我使用package_data上传csv文件.

I use the package_data to upload the csv file.

setup.py

setup.py

import setuptools
import string
import ast
import nltk
import pandas as pd
from nltk.corpus import stopwords
from nltk import sent_tokenize
from nltk import ngrams

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="spamclassifier",
    version="0.1.1",
    author="#####",
    author_email="###########",
    description="A bigram approach for classifying Spam and Ham messages",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="#############",
    packages=setuptools.find_packages(),
    include_package_data=True,
    package_data={'data': ['data/spam_collection.csv']},
    install_requires=["nltk", "pandas"],
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
)

我的项目结构

My project structure

我如何在python文件中称呼此CSV

How I call this csv in the python file

 def classify(self):
     fullCorpus = pd.read_csv("../data/spam_collection.csv", sep="\t", header=None)
     fullCorpus.columns = ["lable", "body_text"]

MANIFEST.in

MANIFEST.in

include README.md
include LICENSE
include data/spam_collection.csv

用pip安装python软件包后,我运行pip show -f spamclassifier列出了软件包中的文件,但未列出csv文件.输出为

After installing the python package with pip I ran pip show -f spamclassifier to list the files in the package and the csv file is not listed. The output was,

Name: spamclassifier
Version: 0.1.3
Summary: A bigram approach for classifying Spam and Ham messages
Home-page: XXXXXXXX
Author: XXXXXXX
Author-email: XXXXXX 
License: UNKNOWN
Location: /home/kabilesh/PycharmProjects/TestPypl3/venv/lib/python3.6/site-packages
Requires: pandas, nltk
Required-by: 
Files:
  spamclassifier-0.1.3.dist-info/INSTALLER
  spamclassifier-0.1.3.dist-info/LICENSE
  spamclassifier-0.1.3.dist-info/METADATA
  spamclassifier-0.1.3.dist-info/RECORD
  spamclassifier-0.1.3.dist-info/WHEEL
  spamclassifier-0.1.3.dist-info/top_level.txt
  spamclassifier/SpamClassifier.py
  spamclassifier/__init__.py
  spamclassifier/__pycache__/SpamClassifier.cpython-36.pyc
  spamclassifier/__pycache__/__init__.cpython-36.pyc

推荐答案

尝试一下:

packages=['spamclassifier'],
package_dir={'spamclassifier': 'spamclassifier'},
package_data={'spamclassifier': ['data/*']},
include_package_data=True

将其他所有内容保持不变.希望对您有帮助

Keep everything else constant. Hope it helps

这篇关于无法将csv文件上传到test.pypi.org的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆