Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with reading a path
#1
i'm having a problem on reading a path that contains a group of images, i have the paths on my desktop but i can't read them

Can you guys help me?

I have the exact code on a computers friend and it runs perfeclty

where is the code

from sklearn.decomposition import NMF
from matplotlib import pyplot as plt
import cv2
import numpy as np
import os
import sys
import statistics

## upload imgs e returns names e imgs
def uploadImg(dir1,dir2):
    cityscape_original = []
    landscape_original = []
    nameList = [[] for _ in range(512)]
    imgList = [[] for _ in range(512)]
    for file in os.listdir('./Desktop/landscape'):
        if file.endswith(".jpg"):
            nameList[0].append(file)
            
            orig = cv2.imread('./Desktop/landscape' + file)
            orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)
            cityscape = cv2.resize(orig,(512,512))
            #cityscape_original.append(cityscape)
            imgList[0].append(cityscape)
    for file in os.listdir('./Desktop/cityscape'):
        if file.endswith(".jpg"):
            nameList[1].append(file)
            orig = cv2.imread('./sktop/cityscape' + file)
            orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)

            landscape = cv2.resize(orig,(512,512))
            #landscape_original.append(landscape)
            imgList[1].append(landscape)
    return nameList,imgList


dir1 = os.listdir('./Desktop/cityscape')
dir2 = os.listdir('./Desktop/landscape')
name,img = uploadImg(dir1, dir2)
And this is my error

Error:
FileNotFoundError Traceback (most recent call last) <ipython-input-8-d8d91223d726> in <module> ----> 1 dir1 = os.listdir('./Desktop/cityscape') 2 dir2 = os.listdir('./Desktop/landscape') 3 name,img = uploadImg(dir1, dir2) FileNotFoundError: [WinError 3] The system cannot find the path specified: './Desktop/cityscape'
thanks for the support
Reply


Messages In This Thread
Problem with reading a path - by gkiller007 - Jan-04-2019, 03:34 PM
RE: Problem with reading a path - by ichabod801 - Jan-04-2019, 03:36 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 03:42 PM
RE: Problem with reading a path - by nilamo - Jan-04-2019, 03:59 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 04:08 PM
RE: Problem with reading a path - by Axel_Erfurt - Jan-04-2019, 04:28 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 04:34 PM
RE: Problem with reading a path - by Axel_Erfurt - Jan-04-2019, 04:41 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 04:49 PM
RE: Problem with reading a path - by nilamo - Jan-04-2019, 05:00 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 05:12 PM
RE: Problem with reading a path - by Axel_Erfurt - Jan-04-2019, 06:21 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 06:32 PM
RE: Problem with reading a path - by Axel_Erfurt - Jan-04-2019, 06:39 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 06:43 PM
RE: Problem with reading a path - by nilamo - Jan-04-2019, 06:52 PM
RE: Problem with reading a path - by gkiller007 - Jan-04-2019, 11:59 PM
RE: Problem with reading a path - by ichabod801 - Jan-05-2019, 01:49 AM
RE: Problem with reading a path - by gkiller007 - Jan-05-2019, 02:27 AM
RE: Problem with reading a path - by snippsat - Jan-05-2019, 03:47 AM
RE: Problem with reading a path - by ichabod801 - Jan-05-2019, 04:18 AM
RE: Problem with reading a path - by gkiller007 - Jan-05-2019, 02:16 PM
RE: Problem with reading a path - by snippsat - Jan-05-2019, 02:40 PM
RE: Problem with reading a path - by gkiller007 - Jan-05-2019, 02:42 PM
RE: Problem with reading a path - by snippsat - Jan-05-2019, 03:26 PM
RE: Problem with reading a path - by gkiller007 - Jan-05-2019, 04:31 PM
RE: Problem with reading a path - by snippsat - Jan-05-2019, 06:34 PM
RE: Problem with reading a path - by gkiller007 - Jan-05-2019, 08:24 PM
RE: Problem with reading a path - by snippsat - Jan-05-2019, 09:11 PM
RE: Problem with reading a path - by gkiller007 - Jan-05-2019, 09:19 PM
RE: Problem with reading a path - by snippsat - Jan-05-2019, 10:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel file reading problem max70990 1 959 Dec-11-2022, 07:00 PM
Last Post: deanhystad
  Loop reading csv file problem faustineaiden 1 1,631 Dec-11-2021, 08:40 AM
Last Post: ibreeden
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,280 Sep-09-2021, 01:25 PM
Last Post: Yoriz
Exclamation Path sacn problem lucky511 10 4,059 Jun-24-2021, 12:09 PM
Last Post: Axel_Erfurt
  Subprocess.Popen() not working when reading file path from csv file herwin 13 15,666 May-07-2021, 03:26 PM
Last Post: herwin
  Strange Problem when reading from excel faryad13 3 2,483 Nov-04-2020, 03:48 PM
Last Post: DeaD_EyE
  problem about maze path finder Simurg 2 2,021 Aug-16-2020, 01:10 PM
Last Post: Simurg
  Reading integers from a file; the problem may be the newline characters JRWoodwardMSW 2 2,085 Jul-14-2020, 02:27 AM
Last Post: bowlofred
  Problem reading data from file player1681 2 3,852 May-22-2020, 08:57 AM
Last Post: player1681
  Problem with reading and writing to file. darktitan 2 2,360 Jul-20-2019, 06:06 PM
Last Post: darktitan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020