[英]python setup.py: install either tensorflow or tensorflow-gpu?
我正在設計一個需要張量tensorflow
的新項目。 由於TensorFlow具有多個安裝( tensorflow
和tensorflow-gpu
),我如何在install_requires
部分中添加兩個都可以呢?
所以這是我的解決方法:
from pkg_resources import DistributionNotFound, get_distribution
from setuptools import setup, find_packages
def get_dist(pkgname):
try:
return get_distribution(pkgname)
except DistributionNotFound:
return None
install_deps = ['numpy', 'tensorflow']
if get_dist('tensorflow') is None and get_dist('tensorflow-gpu') is not None:
install_deps.remove('tensorflow')
setup(..., install_requires=install_deps)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.