我有一个存储库 ,myBigRep
其中包含一个子模块mySmallRep
。该子模块是一个 python 项目,其中有一个setup.py
安装一些命令的脚本。为了设置它,我运行:
$ pip install --editable myBigRep/local/src/mySmallRep/
Run Code Online (Sandbox Code Playgroud)
就是这样。
现在我想克隆到mySmallRep
其他地方,设置其子模块并安装 Python 命令。所以我首先冻结 Python 包:
$ cd myBigRep
$ pip freeze
-e git+git@bitbucket.org:me/mySmallRep.git@d702f237b4c5449dffe5f224a8c361bf983566fc#egg=mySmallRep&subdirectory=../../../../local/src/mySmallRep
$ pip freeze > requirements.txt
$ git add requirements.txt
$ git commit -m "added requirements."
$ git push origin master
Run Code Online (Sandbox Code Playgroud)
现在我克隆并设置所有内容:
$ cd
$ git clone git@bitbucket.org:me/myBigRep.git myBigRepClone
$ cd myBigRepClone
$ git submodule init && git submodule update
$ git submodule foreach git pull origin master
$ pip …
Run Code Online (Sandbox Code Playgroud) 可以下载 NLTK 语料库punkt
并wordnet
通过命令行:
python3 -m nltk.downloader punkt wordnet
Run Code Online (Sandbox Code Playgroud)
如何使用 下载 NLTKrequirements.txt
语料库pip install -r requirements.txt
?
例如,可以通过添加模型的 URL 来下载 spacy 模型requirements.txt
(pip install -r requirements.txt
例如https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz #egg=en_core_web_sm==2.0.0
中requirements.txt
)
我想使用pip freeze > requirements.txt
命令创建requirements.txt并复制到Google Drive以在Google Colab中使用,但出现如下错误:
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/C:/ci/astroid_1592481955828/work'
Run Code Online (Sandbox Code Playgroud)
于是,我打开了requirements.txt
,模块名后面有奇怪的东西开头@ files:\\\~~~
这是一个例子。
requirements.txt
~~~
jupyter-core==4.6.3
jupyterlab==2.2.6
jupyterlab-server @ file:///tmp/build/80754af9/jupyterlab_server_1594164409481/work
Keras==2.3.1
Keras-Applications @ file:///tmp/build/80754af9/keras-applications_1594366238411/work
Keras-Preprocessing==1.1.0
kiwisolver==1.2.0
~~~
Run Code Online (Sandbox Code Playgroud)
我使用 Anaconda 安装了这些模块,并将其存储在名为“TensorFlow”的虚拟环境中。
可以删除@ files:\\\~~~
模块名称后面的东西吗?或者我应该做什么来解决这个问题?
谢谢。
我用下面的方法将我的项目的需求转换成txt文件。
pip freeze > requirements.txt
Run Code Online (Sandbox Code Playgroud)
我尝试使用下面的代码加载生成的txt文件来测试它,但出现以下错误。我该如何解决这个问题。
python -m pip install -r requirements.txt
Usage: pip [options]
ERROR: Invalid requirement: -andas @ file:///C:/ci/pandas_1592833613419/work
pip: error: no such option: -a
-andas @ file:///C:/ci/pandas_1592833613419/work
absl-py==0.11.0
alabaster==0.7.12
anaconda-client==1.7.2
anaconda-navigator==1.9.12
anaconda-project==0.8.3
argh==0.26.2
asn1crypto==1.3.0
astroid @ file:///C:/ci/astroid_1592487315634/work
astropy==4.0.1.post1
astunparse==1.6.3
atomicwrites==1.4.0
attrs==19.3.0
autopep8 @ file:///tmp/build/80754af9/autopep8_1592412889138/work
Babel==2.8.0
backcall==0.2.0
backports.functools-lru-cache==1.6.1
backports.shutil-get-terminal-size==1.0.0
backports.tempfile==1.0
backports.weakref==1.0.post1
bcrypt==3.1.7
beautifulsoup4==4.9.1
bitarray @ file:///C:/ci/bitarray_1594751093906/work
bkcharts==0.2
bleach==3.1.5
bokeh @ file:///C:/ci/bokeh_1593178781838/work
boto==2.49.0
Bottleneck==1.3.2
bower==0.0.0
brotlipy==0.7.0
cachetools==4.1.1
certifi==2020.6.20
cffi==1.14.0
chardet==3.0.4
click==7.1.2
cloudpickle @ file:///tmp/build/80754af9/cloudpickle_1594141588948/work
clyent==1.2.2
colorama==0.4.3
comtypes==1.1.7
conda==4.8.3
conda-build==3.18.11 …
Run Code Online (Sandbox Code Playgroud) 我想在我的requirements.txt
for中设置依赖项tensorflow~=2.5.0
。截至撰写本文时,tensorflow==2.5.0
尚未发布。可用的最新版本是候选版本tensorflow==2.5.0rc3
。我如何简洁地告诉pip
“安装最新的tensorflow
2.5.x 版本,包括候选版本”?
到目前为止我尝试过的:
tensorflow~=2.5.0
ERROR: Could not find a version that satisfies the requirement tensorflow~=2.5.0 (from versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3)
ERROR: No matching distribution found for tensorflow~=2.5.0
Run Code Online (Sandbox Code Playgroud)
tensorflow>2.4.1
ERROR: Could not find a version that satisfies the requirement tensorflow>2.4.1 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 1.15.0rc0, 1.15.0rc1, 1.15.0rc2, 1.15.0rc3, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 1.15.5, 2.0.0a0, 2.0.0b0, 2.0.0b1, 2.0.0rc0, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, …
Run Code Online (Sandbox Code Playgroud) 我有一台配备 Apple M1 芯片组的新 MacBook。要安装tensorflow,我按照此处的说明进行操作,即安装tensorflow-metal
andtensorflow-macos
而不是普通的tensorflow
软件包。
虽然这工作正常,但这意味着我无法运行典型的,pip install -r requirements.txt
只要我们tensorflow
在requirements.txt
. 如果我们改为包含tensorflow-macos
,则会给非 M1 甚至非 macOS 用户带来问题。
我们的库必须在所有平台上运行。是否有一个通用安装命令可以根据计算机是否是 M1 Mac 来安装正确的 TensorFlow 版本?这样我们就可以为requirements.txt
每个人使用一个单一的?
或者,如果这是不可能的,我们可以传递一些标志/选项,例如pip install -r requirements.txt --m1
安装一些变体吗?这里最简单、最优雅的解决方案是什么?
目前,当我们的项目的requirements.txt更新时,我们从头开始重新构建virtualenv以确保一致的结果.问题是我们的requirements.txt非常冗长,对它的更新通常只触及一个包.
是否有任何系统将virtualenv与requirements.txt进行比较并进行最少量的更改以使它们匹配?
我可以自己写这个,如果我能得到pip告诉我它会安装哪个版本给出一个requirements.txt,但我没有看到这样的选项.
我正在尝试以编程方式生成requirements.txt文件.这样我可以将它与第二个.txt文件区分开来.到目前为止,我已经尝试了以下内容,但它们只向控制台输出要求(生成No .txt文件).
到目前为止我已经尝试过了
import pip
pip.main(["freeze",">","requirements.txt"])
Run Code Online (Sandbox Code Playgroud)
和
from subprocess import call
call(["pip","freeze", ">","requirements.txt"])
Run Code Online (Sandbox Code Playgroud)
如果我尝试在终端中手动运行相同的命令,则生成的文件没有问题.有什么建议?
我是Django的新手.
每次我使用安装新库时pip
,我都必须运行pip freeze -l > requirements.txt
,有时我会忘记这一点(错误发生在我的生产环境中).
安装新软件包时,自动运行此命令的最佳方法是什么?
我在用:
Django==1.11.5
Python 3.6.1
Run Code Online (Sandbox Code Playgroud) 在我的变化requirements.txt
,当我运行没有被体现出来:
docker-compose -f docker-compose-dev.yml up -d
Run Code Online (Sandbox Code Playgroud)
docker-compose-dev.yml
version: '3.6'
services:
web:
build:
context: ./services/web
dockerfile: Dockerfile-dev
volumes:
- './services/web:/usr/src/app'
ports:
- 5001:5000
environment:
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgres://postgres:postgres@web-db:5432/web_dev
- DATABASE_TEST_URL=postgres://postgres:postgres@web-db:5432/web_test
depends_on:
- web-db
web-db:
build:
context: ./services/web/project/db
dockerfile: Dockerfile
ports:
- 5435:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
nginx:
build:
context: ./services/nginx
dockerfile: Dockerfile-dev
restart: always
ports:
- 80:80
depends_on:
- web
- client
client:
build:
context: ./services/client
dockerfile: Dockerfile-dev
volumes:
- './services/client:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- 3007:3000 …
Run Code Online (Sandbox Code Playgroud) requirements.txt ×10
python ×8
pip ×6
apple-m1 ×1
conda ×1
corpus ×1
django ×1
docker ×1
git-bash ×1
macos ×1
nltk ×1
python-3.x ×1
subprocess ×1
tensorflow ×1
virtualenv ×1