使用pip在Google Colab上安装软件包

时间:2020-07-22 22:29:16

标签: python pip

我正在尝试在Google colab上运行包含以下代码的bash文件“ run.sh”:

pip uninstall tensorflow
pip install tensorflow=={1.14}
wget -P weights https://pjreddie.com/media/files/yolov3.weights
python detect.py $1

运行此操作会引发以下错误:

ERROR: Could not find a version that satisfies the requirement tensorflow=={1.2} (from versions: 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.4.1, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.8.0rc0, 1.8.0rc1, 1.8.0, 1.9.0rc0, 1.9.0rc1, 1.9.0rc2, 1.9.0, 1.10.0rc0, 1.10.0rc1, 1.10.0, 1.10.1, 1.11.0rc0, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.12.0rc0, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.2, 1.12.3, 1.13.0rc0, 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, 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.1.0rc0, 2.1.0rc1, 2.1.0rc2, 2.1.0, 2.1.1, 2.2.0rc0, 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2)
ERROR: No matching distribution found for tensorflow=={1.2}

但是,在google colab单元格中运行以下代码就可以了。

!pip uninstall tensorflow 
!pip install tensorflow=={1.14}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

请勿在版本import time list = [1,2,3,4,2323449,1,525] def Search(arr): # sorting i = 0 print(f"Given list: {list}") print("Sorting...") time.sleep(1.75) for i in range(len(list)): if i + 1 >= len(list): break elif list[i + 1] < list[i]: list.sort() print("List has been sorted ") print(f"Sorted list: {list}") #--------------------------------------- # searching inputCheck = True while inputCheck: n = input("Enter a number to find in the list: ") try: n=int(n) # if input is valid value then seaching will be done so store that number inputCheck = False except ValueError or TypeError: print("Please enter a number") time.sleep(0.6) print("Searching...") l = 0 h = len(list) - 1 while l <= h: mid = (l + h) // 2 if list[mid] == n: pos = mid print(f"Found at index {pos}") break else: print(n) if list[mid] < n: l = mid+1 # as index mid has already checked so set l=mid+1 else: h = mid-1 # mid has already checked so set h=mid-1 Search(list) 前后使用花括号({1.14})。只需tensorflow作为版本号即可完成工作。