简体   繁体   English

如何从 setup.py install_requires 列表中安装 PyTorch 和相关工具?

[英]How does one install PyTorch and related tools from within the setup.py install_requires list?

I was trying to test the pip install -e.我试图测试pip install -e. on my library ultimate-utils after changing laptops but I keep getting errors of this type:更换笔记本电脑后在我的图书馆 Ultimate-utils上,但我不断收到这种类型的错误:

(uutils_env) brandomiranda~/ultimate-utils ❯ pip install -e .                      
Obtaining file:///Users/brandomiranda/ultimate-utils
  Preparing metadata (setup.py) ... done
ERROR: Could not find a version that satisfies the requirement torchvision==0.10.1 (from ultimate-utils) (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3)
ERROR: No matching distribution found for torchvision==0.10.1

or或者

(uutils_env) brandomiranda~/ultimate-utils ❯ pip install -e .
Obtaining file:///Users/brandomiranda/ultimate-utils
  Preparing metadata (setup.py) ... done
ERROR: Could not find a version that satisfies the requirement torch==1.9.1 (from ultimate-utils) (from versions: none)
ERROR: No matching distribution found for torch==1.9.1

where it seems it stopped working to install anything related to pytorch for some reason.由于某种原因,它似乎停止安装与 pytorch 相关的任何东西。

I tried updating pip and conda but it did not work.我尝试更新 pip 和 conda 但它没有用。 I did:我做了:

pip install --upgrade pip
conda update conda
conda update conda-build
conda update -n base -c defaults conda
conda update --name base conda
conda update --all
conda install anaconda

but none seem to work.但似乎没有一个工作。

my setup.py looks as follows:我的 setup.py 如下所示:

"""
conda create -n uutils_env python=3.9
conda activate uutils_env
conda remove --all --name uutils_env
rm -rf /Users/brando/anaconda3/envs/uutils_env

pip install -e ~/ultimate-utils/ultimate-utils-proj-src/

pip install ultimate-utils

To test it:
python -c "import uutils; uutils.hello()"
python -c "import uutils; uutils.torch_uu.hello()"

python -c "import uutils; uutils.torch_uu.gpu_test_torch_any_device()"
python -c "import uutils; uutils.torch_uu.gpu_test()"

PyTorch:
    basing the torch install from the pytorch website as of this writing: https://pytorch.org/get-started/locally/
    pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

refs:
    - setup tools: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#using-find-or-find-packages
"""
from setuptools import setup
from setuptools import find_packages
import os

# import pathlib

here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='ultimate-utils',  # project name
    version='0.5.3',
    description="Brando's ultimate utils for science, machine learning and AI",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url='https://github.com/brando90/ultimate-utils',
    author='Brando Miranda',
    author_email='brandojazz@gmail.com',
    python_requires='>=3.9.0',
    license='MIT',
    package_dir={'': 'ultimate-utils-proj-src'},
    packages=find_packages('ultimate-utils-proj-src'),  # imports all modules/folders with  __init__.py & python files

    # for pytorch see doc string at the top of file
    install_requires=[
        # 'torch==1.9.1',
        'torchvision==0.10.1',
        'torchaudio==0.9.1',
        'dill',
        'networkx>=2.5',
        'scipy',
        'scikit-learn',
        'lark-parser',
        'torchtext==0.10.1',
        'tensorboard',
        'pandas',
        'progressbar2',
        'transformers',
        'requests',
        'aiohttp',
        'numpy',
        'plotly',
        'wandb',
        'matplotlib',
        # 'seaborn'

        # 'pygraphviz'  # removing because it requires user to install graphviz and gives other issues
    ]
)

the dir structure is simple:目录结构很简单:

在此处输入图像描述

How do I fix this and what is not working?我该如何解决这个问题,什么不起作用?

I am trying to avoid having to run pip commands outside like:我试图避免在外部运行 pip 命令,例如:

conda install pytorch torchvision torchaudio -c pytorch

at least for cpu in my local laptop ...if I can install gpu ones automatically with a flag it could be nice but for future work...至少对于我本地笔记本电脑中的 cpu ...如果我可以自动安装带有标志的 gpu 可能会很好,但对于未来的工作......

Btw, I prefer no requirements.txt solutions if possible, but post those too in case nothing else works.顺便说一句,如果可能的话,我更喜欢没有 requirements.txt 解决方案,但也发布这些解决方案以防万一。


This is for an intel mac 2013, but I will have an m1 max in 2 months, so those answers are also welcomed!这是针对英特尔 mac 2013 的,但我将在 2 个月内获得最大 m1,因此也欢迎这些答案!


still fails:仍然失败:

(uutils_env) brandomiranda~/ultimate-utils ❯ pip install -e .
Obtaining file:///Users/brandomiranda/ultimate-utils
  Preparing metadata (setup.py) ... done
ERROR: Could not find a version that satisfies the requirement torch<1.10.0,>=1.4.0 (from ultimate-utils) (from versions: none)
ERROR: No matching distribution found for torch<1.10.0,>=1.4.0

Related resources I tried:我试过的相关资源:

See this Why is python using 3.8.1 and 3.9, then fail to install packages (ERROR: Package pkg requires a different Python: 3.8.1 not in '>=3.9.0')?看到这个为什么 python 使用 3.8.1 和 3.9,然后安装包失败(错误:Package pkg 需要不同的 ZA7F5F35426B927411FC9231B56'382173Z=.9.0 中没有) for a more complete answer but the summary is that pytorch seems to not be working right now reliable with python 3.10 so I created an env with 3.9 and then it installed what I needed.以获得更完整的答案,但总结是 pytorch 现在似乎无法与 python 3.10 可靠地一起工作,所以我创建了一个 3.9 的环境,然后它安装了我需要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在python setup.py install_requires列表中传递参数 - Passing arguments in python setup.py install_requires list 如何使用 install_requires 从 setup.py 安装 git+https:// - How to install git+https:// from setup.py using install_requires 如何从 setup.py 安装 `install_requires` 中列出的软件包而不安装主 package? - How to install packages listed in `install_requires` from setup.py without installing the main package? 如何在setup.py中访问setuptools的install_requires安装的模块? - How to access a module installed by setuptools' install_requires within setup.py? 在涉及 Cython 的 setup.py 中,如果 install_requires,那么如何从库中导入一些东西? - In a setup.py involving Cython, if install_requires, then how can from library import something? python setup.py install 忽略 install_requires - python setup.py install ignores install_requires setup.py dependency_links 未搜索 install_requires - setup.py dependency_links not searched for install_requires Pip不会使用install_requires安装在setup.py中声明的依赖项 - Pip does not install dependencies declared in setup.py with install_requires 在setup.py中对install_requires进行“或......或......”区分 - Make an “either… or… ” distinction for install_requires in setup.py setup.py中的install_requires取决于安装的Python版本 - install_requires in setup.py depending on installed Python version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM