【发布时间】:2018-08-06 13:21:54
【问题描述】:
我在 windows 上使用 pycharm 开发了一个项目,我想部署在 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) Virtual Environment is not Portable from Windows to Linux
有什么解决办法吗?
【问题讨论】:
-
它可以使用
conda env export输出并删除仅适用于win-64的包。有些可能需要用 linux 等效替换。我认为在 WSL 下安装 conda 可以解决你的一些问题:这样做你可以在 windows 下直接使用linux-64包进行开发。请注意,我还不能完全测试这个配置。 -
也许:如果您不需要固定所有依赖版本,
pipreqs或类似工具可能只导出通常更平台不变的顶级依赖项,并且将请求特定于平台的依赖项一经请求。但是这有很多失败的机会,因为有些包没有直接在源代码中使用,必须手动安装。