小编tbo*_*one的帖子

AccessDenied for ListObjectsV2 操作 S3 存储桶

在 GitlabCi 期间,我得到:“致命错误:调用 ListObjectsV2 操作时发生错误(AccessDenied):拒绝访问”

我的存储桶策略:

{
"Version": "2008-10-17",
"Statement": [
    {
        "Sid": "AllowPublicRead",
        "Effect": "Allow",
        "Principal": {
            "AWS": "*"
        },
        "Action": "s3:*",
        "Resource": "arn:aws:s3:::BUCKET-NAME/*"
    }
]
Run Code Online (Sandbox Code Playgroud)

}

在 gitlabCI 设置中:

  • AWS_ACCESS_KEY_ID:您的 AWS-ACCESS-KEY-ID
  • AWS_SECRET_ACCESS_KEY:Your-AWS-SECRET-ACCESS-KEY
  • S3_BUCKET_NAME:YOUR-S3-BUCKET-NAME
  • DISTRIBUTION_ID: CLOUDFRONT-DISTRIBUTION-ID

我的 .gitlab-ci.yml

image: docker:latest

stages:
  - build
  - deploy

build:
  stage: build
  image: node:8.11.3
script:
  - export API_URL="d144iew37xsh40.cloudfront.net"
  - npm install
  - npm run build
  - echo "BUILD SUCCESSFULLY"
artifacts:
   paths:
    - public/
expire_in: 20 mins
environment:
name: production
only:
   - master
deploy: …
Run Code Online (Sandbox Code Playgroud)

continuous-integration amazon-s3 gitlab-ci

7
推荐指数
2
解决办法
2万
查看次数

使用 Pandas DataFrame 重命名列值

在我的数据框中的一列中,我有五个值:

1,G,2,3,4
Run Code Online (Sandbox Code Playgroud)

如何使它将所有“G”的名称更改为 1

我试过:

df = df['col_name'].replace({'G': 1})
Run Code Online (Sandbox Code Playgroud)

我也试过:

df = df['col_name'].replace('G',1)
Run Code Online (Sandbox Code Playgroud)

“G”其实就是1(不知道为什么会有混合命名)

编辑:

正常工作:

df['col_name'] = df['col_name'].replace({'G': 1})
Run Code Online (Sandbox Code Playgroud)

python dataframe python-3.x pandas

7
推荐指数
1
解决办法
1万
查看次数

将 jupyter notebook 更新到 python 3.7

我已经安装了 3.73 版的 python,但对于 jupyter 笔记本,我安装了3.6.8. 如何在 jupyter notebook 上将 python 升级到 3.7+ 版本?

我试过:

 conda update jupyter

 conda upgrade notebook
Run Code Online (Sandbox Code Playgroud)

当我在 virtual env python -VI 中输入终端时得到 3.73 但是当我在 jupyter 中检查它时:

 from platform import python_version
 print(python_version())
Run Code Online (Sandbox Code Playgroud)

我明白了3.6.8

python jupyter-notebook

5
推荐指数
1
解决办法
8111
查看次数

Docker 安装问题 (ubuntu 20.04 LTS) - E: 存储库 'https://download.docker.com/linux/ubuntu\Release' 没有 Release 文件

我在虚拟机上安装 docker 时遇到问题。\n我已按照以下步骤操作:

\n

1. 旧版本的 Docker 称为 docker、docker.io 或 docker-engine。如果安装了这些,请卸载\n它们:

\n

sudo apt-get remove docker docker-engine docker.io containerd runc

\n

2.更新apt包索引

\n

sudo apt-get update

\n

3. 安装软件包以允许 apt 通过 HTTPS 使用存储库:

\n
   sudo apt-get install \\\n   apt-transport-https \\\n   ca-certificates \\\n   curl \\\n   gnupg \\\n   lsb-release\n
Run Code Online (Sandbox Code Playgroud)\n

4.添加Docker\xe2\x80\x99s官方GPG密钥:

\n

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

\n

5. 使用以下命令设置稳定存储库:

\n
   echo \\\n     "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]\n   https://download.docker.com/linux/ubuntu \\\n      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >\n   /dev/null\n
Run Code Online (Sandbox Code Playgroud)\n …

linux ubuntu apt-get docker

5
推荐指数
1
解决办法
1万
查看次数

将单元格的输出保存为 jupyter notebook 中的 txt 文件

我非常想将最后一个单元格的输出保存在一个 txt 文件中。

 q = [rng.next () for _ in range (0, 25000000)]
Run Code Online (Sandbox Code Playgroud)

我知道我可以使用 pandas 数据框,但我需要 txt 文件来执行 Diehard 测试。在 jupyter notebook 中可行吗?执行Dieharder Suite可能需要什么类型的数据?

我几乎可以肯定,一旦我做了类似的事情,不幸的是我不记得是怎么做的,我找不到明确的答案

下面是我的 LCG 随机数生成器的代码:

import numpy as np

class LCG(object):

    UZERO: np.uint32 = np.uint32(0)
    UONE : np.uint32 = np.uint32(1)

    def __init__(self, seed: np.uint32, a: np.uint32, c: np.uint32) -> None:
        self._seed: np.uint32 = np.uint32(seed)
        self._a   : np.uint32 = np.uint32(a)
        self._c   : np.uint32 = np.uint32(c)

    def next(self) -> np.uint32:
        self._seed = self._a * self._seed + self._c …
Run Code Online (Sandbox Code Playgroud)

python random jupyter-notebook

3
推荐指数
1
解决办法
6675
查看次数

KeyError: '文件名' (Pandas)

建模时出现此错误。我无法弄清楚这个错误来自哪里。

整个算法旨在描述产品(衣服)。这部分识别衣服的颜色。

数据框正确加载。

下面我放了很多代码,因为我不知道我到底哪里出错了。

# path to the training set
TRAIN_LABELS_FILE = "train/labels.txt"
# path to the validation set
VAL_LABELS_FILE = "val/labels.txt"
# path to the test set
TEST_LABELS_FILE = "test/labels.txt"
# Color names
COLOR_FILE = "names.txt"

# Specify image size
IMG_WIDTH = 224
IMG_HEIGHT = 224
CHANNELS = 3

color = pd.read_csv(COLOR_FILE)
color = color.T
color_list = list(color.iloc[0])
color_list.insert(0,'beige')
color_list.insert(0,'path')

train = pd.read_csv(TRAIN_LABELS_FILE,sep=" ",names=color_list)

def crop_image_from_gray(img, tol=7):
    """
    Applies masks to the orignal image and 
    returns the a preprocessed …
Run Code Online (Sandbox Code Playgroud)

python pandas keras tensorflow

3
推荐指数
1
解决办法
1893
查看次数

将单元格的输出保存在jupyter笔记本中,并在每个数字后换行

我将单元格的输出保存为 txt 文件,如下所示:

第一个单元格:

%%capture cap --no-stderr
print(q)
Run Code Online (Sandbox Code Playgroud)

第二个单元格:

with open('output.txt', 'w') as f:
    f.write(cap.stdout)
Run Code Online (Sandbox Code Playgroud)

下面是我想保存的一小段代码:

#%%
np.seterr(over='ignore')

a = np.uint32(1664525)
c = np.uint32(1013904223)
seed = np.uint32(1)

rng = LCG(seed, a, c)
q = [rng.next() for _ in range(0, 2500000)]
Run Code Online (Sandbox Code Playgroud)

文件已保存,但是生成的数字由逗号分隔,但我希望每个生成的数字由新行而不是逗号分隔

我尝试将“w”更改为“a”并添加“\ n”,如下所示,但它对我不起作用。

with open('output.txt', 'a') as f:
    f.write("\n")
Run Code Online (Sandbox Code Playgroud)

python jupyter-notebook

2
推荐指数
1
解决办法
4628
查看次数

AttributeError: 模块“enum”没有属性“IntFlag” - fastai install

当我尝试安装fastai( pip install fastai) 时,出现以下错误:

AttributeError: module 'enum' has no attribute 'IntFlag'
Run Code Online (Sandbox Code Playgroud)

完整追溯:

 Installing build dependencies ... error
  ERROR: Complete output from command /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-b8vreosn/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'numpy==1.13.3; python_version=='"'"'2.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.13.3; python_version=='"'"'3.5'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.13.3; python_version=='"'"'3.6'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.14.5; python_version>='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'2.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.5'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.6'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version>='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'':
  ERROR: Traceback (most recent call …
Run Code Online (Sandbox Code Playgroud)

python pytorch fast-ai

2
推荐指数
1
解决办法
2756
查看次数