Google colab踩坑

本文详细介绍了如何在Google Colab中使用Google Drive存储数据,设置Anaconda环境,以及解决安装过程中常见的三个问题,包括升级setuptools、pip和处理PyYAML卸载难题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.在使用的时候,先将数据传入Google Drive中,然后在Colab中连接Google Colab

from google.colab import drive
drive.mount('/content/drive')

2.进入到自己的文件夹下:

在colab中,直接这样做就可以

cd 想要进入的文件夹名字/

3.安装Anaconda来配置需要的安装包:

!wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
!chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
!bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local
 
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')

4.Linux下Anaconda的虚拟环境创建、激活

虚拟环境创建:

!conda create -n 虚拟环境名称 python=3.7

激活虚拟环境:

!source cnonda activate 虚拟环境

虚拟环境被激活之后,就不用进行其他的操作了,激活了虚拟环境后,想要运行的python文件就会在这个虚拟环境下运行

安装各种依赖库时常会出现的错误有三个:

(1)Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-nr4ydx_8/opencv-python/

!pip install --upgrade setuptools

(2)Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ud_idlo6/opencv-python/

!python -m pip install --upgrade pip

(3)ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

pip install PyYAML --ignore-installed

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jay_Mapp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值