我已经在windows上开发了一个使用py魅力的项目,我希望部署在一个ubuntu服务器上。
我试图使用以下命令创建一个requirements.txt:
conda list -e > requirements.txt
conda list > requirements.txt根据选项的不同,requirements.txt看起来类似于其中的任何一个:
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
@EXPLICIT
https://repo.anaconda.com/pkgs/main/win-64/blas-1.0-mkl.tar.bz2
https://repo.anaconda.com/pkgs/main/win-64/ca-certificates-2018.03.07-0.tar.bz2
https://repo.anaconda.com/pkgs/main/win-64/icc_rt-2017.0.4-h97af966_0.tar.bz2
https://repo.anaconda.com/pkgs/main/win-64/intel-openmp-2018.0.3-0.tar.bz2或者这个
# packages in environment at C:\ProgramData\Anaconda2\envs\myenvs:
#
# Name Version Build Channel
anyjson 0.3.3 py36h1110a06_1
arrow 0.12.1 py36_1
asn1crypto 0.24.0 py36_0
babel 2.6.0 py36_0或者这个
name: myenv
channels:
- defaults
dependencies:
- anyjson=0.3.3=py36h1110a06_1
- arrow=0.12.1=py36_1
- asn1crypto=0.24.0=py36_0
- babel=2.6.0=py36_0
- blas=1.0=mkl无论我如何尝试这样做,我在ubuntu机器上都会出现错误,在某些情况下是因为包是用于windows的:(/win-64/)
https://repo.anaconda.com/pkgs/main/win-64/ca-certificates-2018.03.07-0.tar.bz2 我读过很多文档,但我似乎无法得到我想要的东西。Conda (Python)虚拟环境从Windows到Linux是不可移植的
有解决办法吗?
发布于 2019-02-21 07:26:42
默认情况下,conda将使用生成导出您的环境,但是构建可以是特定于平台的。
一个对我有用的解决方案是使用--no-build标志:
$ conda env export --no-build > environment.yml希望这能有所帮助。
发布于 2021-03-15 19:55:11
在处理同样的问题时,我在Anaconda文档中找到了这个:
Conda在从规范文件安装时不检查体系结构或依赖项。要确保包正确工作,请确保文件是从工作环境创建的,并在相同的体系结构、操作系统和平台(如linux-64或osx-64 )上使用该文件。
发布于 2022-02-17 18:15:25
替代方案
作为另一种选择,您只导出您添加的依赖项,而不是使用conda env export --from-history导出任何传递的dep,这会导致类似的情况
name: email_scraper
channels:
- https://conda.anaconda.org/conda-forge/
- defaults
dependencies:
- python=3.9
- img2pdf
- python-dotenv
- google-cloud-storage
- psycopg2
- pypdf2
- pytest
- google-cloud-logging虽然这会丢失版本,所以您可能需要通过交叉引用其他environmnet.yaml文件来手动添加它们(乏味)。
与平台相关的问题经常发生在底层的传递依赖项中。您基本上是在特定性和可转换性之间进行权衡。默认的export是一个高度特定的环境,运行在单个OS平台上。后者更通用,但在不同的操作系统上内部可能有所不同。
如果您在2022年来到这里,您可能希望将诗词作为包管理器来查看。
https://stackoverflow.com/questions/51708668
复制相似问题