添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

When I build a deep learning image dataset and use Spyder to package it, the following error occurs, what should I do?

Traceback (most recent call last):

File “”, line 1, in
runfile(‘D:/360Downloads/VS/1203_2.py’, wdir=‘D:/360Downloads/VS’)

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\spyder_kernels\customize\spydercustomize.py”, line 827, in runfile
execfile(filename, namespace)

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\spyder_kernels\customize\spydercustomize.py”, line 110, in execfile
exec(compile(f.read(), filename, ‘exec’), namespace)

File “D:/360Downloads/VS/1203_2.py”, line 93, in
x_train, y_train,x_val,y_val=datacreate(root)

File “D:/360Downloads/VS/1203_2.py”, line 53, in datacreate
for batch_index, batch in train_data:

File “D:/360Downloads/VS/1203_2.py”, line 37, in getitem
img = Image.open(root+fn).convert(‘L’).resize((image_size,image_size))

File “C:\Users\16147\Anaconda3\envs\tensorflow\lib\site-packages\PIL\Image.py”, line 2766, in open
fp = builtins.open(filename, “rb”)

OSError: [Errno 22] Invalid argument: ‘C:/Users/16147/Desktop/ss/shuiguo2/C:/Users/16147/Desktop/ss/shuiguo2/01h.bmp’

This error is raised, if you pass an invalid file path to a method which tries to open this file.
Could you check the path and verify, that this file really exists in this location?

	def pushButtonOuvrirClicked(self):
		print("Bouton <OUVRIR> appuyé")
        if self.lineEditChemin.text()=="":
			self.filename=QFileDialog.getOpenFileName(self, 'Ouvrir fichier', os.getenv('HOME')) 
		else:
			info=QFileInfo(self.lineEditChemin.text()) 
			print (info.absoluteFilePath()) # debug	
			self.filename=QFileDialog.getOpenFileName(self, 'Ouvrir fichier', info.absoluteFilePath())
		print(self.filename)
		self.lineEditChemin.setText(self.filename[0]) 
		myFile=open(self.filename[1],'r')
		myFileContent=open(myFile) 
		myFile.close()
		self.textEdit.setText(myFileContent) 

and thi is the error
(‘C:/Users/hp/Desktop/CNC Data/drawing GCODE/Lamborghini Avantador.gcode’, ‘All Files ()’)
Traceback (most recent call last):
File “c:/Users/hp/Desktop/machine cnc/cnc pyqt5/FinalCodeGUIMain.py”, line 1959, in pushButtonOuvrirClicked
myFile=open(self.filename[1],‘r’) # ouvre le fichier en lecture
OSError: [Errno 22] Invalid argument: 'All Files (
)’

I think the usage of self.filename[1] might be wrong, as the Qt documentation gives the return type as:

(fileNames, selectedFilter)

So I assume self.filename[0] will contain all file names, while self.filename[1] would contain the selectedFilter class, which would fit the error message:

‘All Files ( )’

that give me this error
File “c:/Users/hp/Desktop/machine cnc/cnc pyqt5/FinalCodeGUIMain.py”, line 1960, in pushButtonOuvrirClicked
myFileContent=open(myFile)
TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper

I’m not deeply familiar with the Qt Python API, but it seems you would need to use the self.filename[0].name attribute.

PS: You might get a better and faster answer on StackOverflow or a Qt support forum, as these errors are unrelated to PyTorch. :wink:

I have written a python code to upload file in sharepoint from local machine directory. It is working fine in local machine. When i try to upload any file from C drive directly of virtual machine to sharepoint, i am facing below error. But sharepoint is getting opened in virtual machine with my credentials. Can you let me know it is an operating system issue or as virtual machine has many users, there is some security concern.

from sharepoint import SharePointSite, basic_auth_opener
import subprocess
import shutil
server_url = "https://abc.sharepoint.com/"
site_url = server_url + "sites/Report/"
opener = basic_auth_opener(server_url, "email ID", "Password")
site = SharePointSite(site_url, opener)
subprocess.call(r'net use Y: https://abc.sharepoint.com/sites/Report/')
shutil.copy(r"C:/log.txt","Y:\\",follow_symlinks=True)

error is as under: File “C:\ProgramData\Anaconda3\lib\shutil.py”, line 121, in copyfile with open(dst, ‘wb’) as fdst:

FileNotFoundError: [Errno 2] No such file or directory: ‘Y:’