【问题标题】:What is requirements for a python project that uses curses?使用 curses 的 python 项目有什么要求?
【发布时间】:2020-10-05 10:24:18
【问题描述】:

我是使用 Pypi 打包程序的新手。我关注了a tutorial,但并没有说太多要求。

在我的项目中,我使用了一些包,例如:

import datetime, time
from time import sleep
import sys, os
import datetime
import pickle
import shlex
import re
import textwrap
import json
import newspaper #This is a github project

import curses as cur # This must work on both linux and windows
from curses import wrapper
from curses.textpad import rectangle
from pathlib import Path
from urllib.parse import urlparse
from appdirs import *

首先,我不知道requirements.txt中一定是哪一个。

newspaper3k 是一个 github 项目,但有一个 pypi 包 hereappdirs也一样。

但是,主要需要的包是curses。它必须适用于 Windows 和 Linux。我猜在 Windows 中,有一个名为 windows-curses 的包。 Linux 呢?以及安装程序如何知道安装哪个?请指导我,尤其是curses

【问题讨论】:

    标签: python setuptools ncurses pypi


    【解决方案1】:

    如果你想安装一个 python 包及其依赖项,你不需要把它们都列出来。 Pip 也将解决并安装它们。要安装newspaper3k,您只需要运行以下命令

    pip install newspaper3k
    

    pip 会处理剩下的事情。

    关于ncurses,它是标准python 包的一部分。您可以找到更多信息here

    requirements.txt 是一种指定项目依赖关系的方法。它是一个简单的文本文件,列出了所需的库。它在管理适当的库版本时很方便。例如,您可以添加以下行

    newspaper3k==0.2.8
    

    然后运行

    pip install -r requirements.txt
    

    你可以在requirements.txthere阅读更多内容。

    【讨论】:

    • 你的意思是因为我已经导入了它们,然后 pip install 任何需要的文件而不需要我在 require.txt 中指定它们?
    • 你需要pip安装依赖然后导入。即使您在requirements.txt 中指定它们,您仍然需要在运行代码之前执行pip install -r requirements.txt。管理依赖最安全的方法是通过 virtualenvs,for instance
    • 我怎样才能让我的python文件成为可执行文件,因为这是我最初的目标,但后来我发现pypi只是将我的文件打包为要导入python的包,我希望它是一个软件一个可以跑...
    • 我想这就是解决方案:python-packaging.readthedocs.io/en/latest/…(对吗?)创建一个调用主函数的脚本
    • 我一直没有用这种方式使用python。 This 可能会提供解决方案。
    猜你喜欢
    • 2022-12-30
    • 1970-01-01
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 2015-04-09
    • 2012-05-02
    • 2021-07-11
    相关资源
    最近更新 更多