Invalid argument error python

An error is a problem in python incurred while compiling the code. For example, an error is raised when python cannot understand a given code because it

An error is a problem in python incurred while compiling the code. For example, an error is raised when python cannot understand a given code because it failed to adhere to the syntax. There are several types of error in python, such as SyntaxError, RuntimeError, IndentationError, etc. OSError errno22 invalid argument is one such type of python error. We will first understand each of the components of the error separately.

What is OSError?

OSError is the type of error in OSError : [errno22] invalid argument. OSError is an error class for the OS module. It is a built-in exception in python, which is raised. It is raised when the error occurs due to some system failure. I/O failures also give rise to OSErrors.

When the disk is full, or the file cannot be found, OSError is raised. The subclasses of OSError are BlockingIOError, ChildProcessError, ConnectionError, FileExistsError, FileNotFoundError, etc. OSError itself is derived from the EnvironmentError.

What is errorno22 invalid argument?

As the name suggests, invalid argument errors occur when an invalid argument is passed to a function. If a function was expecting an argument of a particular data type but instead received an argument of a different data type, it will throw an invalid argument error.

Example:

import tensorflow as tf
tf.reshape(1,2)

The above code will raise invalid argument error.

InvalidArgumentError                  Traceback (most recent call last)
<ipython-input-14-a2040abbdb7e> in <module>()
      1 import tensorflow as tf
----> 2 tf.reshape(1,2)

The tf.reshape() function was expecting a tensor as an argument. But instead, it received 1 and 2 as the argument.

‘OSError : [errno22] invalid argument’ while using read_csv()

Read_csv() is a function in pandas which is used to read a csv file in python. We can read a csv file by accessing it through a URL or even locally. While reading a csv file using read_csv, python can throw OSError : [errno22] invalid argument error.

Let us try to understand it with the help of an example. The below code has been executed in python shell to access local files. First, we shall import the pandas file to use read_csv()

Now, we shall try to access a csv file.

file = read_csv("C:textfile.csv")

The above line of code will raise the below error.

OSError: [Errno 22] Invalid argument: 'C:textfile.csv' 

The reason behind the error is that python does not consider the backslash. Because of that, it showed oserror invalid argument. So what we have to do is that instead of a backslash, we have to replace it with a forwarding slash.

file = read_csv("C:/textfile.csv")

Th error has been resolved now.

‘OSError : [errno22] invalid argument’ while using open()

We can get OSError : [errno22] invalid argument error while opening files with the open() function. The open() function in python is used for opening a file. It returns a file object. Thus, we can open the file in read, write, create or append mode.

Let us understand the error by taking an example. We shall try to open a .txt file in read mode using open(). The file would be returned as an object and saved in variable ‘f’.

f = open("C:textfile.txt","r")

The code will throw the below error.

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    f = open("C:textfile.txt","r")
OSError: [Errno 22] Invalid argument: 'C:textfile.

The OSError : [errno22] invalid argument error has been thrown because of the same reason as before. Here also, python fails to recognize the backslash symbol. On replacing backslash with forward slash, the error will be resolved.

f = open("C:/textfile.txt","r")

Must Read | 2 Causes of TypeError: ‘Tuple’ Object is not Callable in Python

‘OSError : [errno22] invalid argument’ while reading image using open()

The above error can appear while opening an image using the open() function even though the backslash character has been replaced with forward slash. Let us see the error using an example.

image = open("C:/image1.jpg")

The error thrown would be:

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    image = open("‪C:/image1.jpg")
OSError: [Errno 22] Invalid argument: 'u202aC:/image1.jpg'

This error mainly occurs because of the copying of the file path. The Unicode characters also get copied sometimes when we copy the file path from our local system or the internet.

The Unicode character, ‘u202a’ in the above example, is not visible in the file pathname. ‘u202a’ is the Unicode control character from left to right embedding. So, it causes the above oserror invalid arguments.

The solution to this is straightforward. We simply have to type the URL manually instead of copying it. Thus, the Unicode character will no longer be in the URL and the error will be resolved.

OSError errno 22 invalid argument

As seen above, initially the program was showing an error because the Unicode character was present even though it was not visible. But, the error gets resolved when the second time the same code was typed manually.

‘OSError : [errno22] invalid argument’ while reading image using savefig()

Savefig() function in python is used to save an image locally, which has been plotted using the matplotlib library. It is accessed using plt.savefig().

import matplotlib.pyplot as plt
plt.savefig("image.png")

While using savefig() function, OSError : [errno22] invalid argument error can also occur. This error too occurs due to the same reasons as mentioned above. When we try to save the image file, we must ensure that the file is not saved with colons, brackets, or backslash.

Doing so will raise the oserror. Next, check if the file is not saved with those characters and remove them if they are present. This shall resolve the error.

FAQ’s

Q. What is oserror: (errno 22) invalid argument datetime?

A. The datetime module in python is a module that is used for manipulating date and time. OSError: (errno 22) invalid argument datetime occurs when we are using fromtimestamp. Checking the units will solve the error.

Q. What is oserror: (errno 22) invalid argument saving the file?

A. The OSError: (errno 22) invalid argument occurs may also occur when one is trying to save a file. For example: adding an unnecessary semicolon to the filename also causes the error. It is because windows do not allow semi-colons in file names.


That was it for OSError: (errno 22) invalid argument. If you have anything to share, we would love to hear about it in the comments. Keep learning because you can never learn enough!

Happy Learning!

def choose_option(self):
        if self.option_picker.currentRow() == 0:
            description = open(":/description_files/program_description.txt","r")
            self.information_shower.setText(description.read())
        elif self.option_picker.currentRow() == 1:
            requirements = open(":/description_files/requirements_for_client_data.txt", "r")
            self.information_shower.setText(requirements.read())
        elif self.option_picker.currentRow() == 2:
            menus = open(":/description_files/menus.txt", "r")
            self.information_shower.setText(menus.read())

I am using resource files and something is going wrong when i am using it as argument in open function, but when i am using it for loading of pictures and icons everything is fine.

Cory Kramer's user avatar

Cory Kramer

112k15 gold badges164 silver badges211 bronze badges

asked Aug 30, 2014 at 15:45

eugene's user avatar

3

That is not a valid file path. You must either use a full path

open(r"C:description_filesprogram_description.txt","r")

Or a relative path

open("program_description.txt","r")

answered Aug 30, 2014 at 15:47

Cory Kramer's user avatar

Cory KramerCory Kramer

112k15 gold badges164 silver badges211 bronze badges

2

Add ‘r’ in starting of path:

path = r"D:Folderfile.txt"

That works for me.

סטנלי גרונן's user avatar

סטנלי גרונן

2,87923 gold badges48 silver badges66 bronze badges

answered Mar 18, 2020 at 7:47

shailu's user avatar

shailushailu

1701 silver badge10 bronze badges

2

I also ran into this fault when I used open(file_path). My reason for this fault was that my file_path had a special character like "?" or "<".

tuomastik's user avatar

tuomastik

4,3915 gold badges35 silver badges47 bronze badges

answered Jul 20, 2018 at 16:20

wolfog's user avatar

wolfogwolfog

7117 silver badges10 bronze badges

1

I received the same error when trying to print an absolutely enormous dictionary. When I attempted to print just the keys of the dictionary, all was well!

answered Jul 13, 2018 at 17:57

duhaime's user avatar

duhaimeduhaime

24.6k15 gold badges163 silver badges209 bronze badges

In my case, I was using an invalid string prefix.

Wrong:

path = f"D:Folderfile.txt"

Right:

path = r"D:Folderfile.txt"

answered Mar 6, 2020 at 11:55

RTD's user avatar

RTDRTD

5856 silver badges19 bronze badges

I had the same problem
It happens because files can’t contain special characters like «:», «?», «>» and etc.
You should replace these files by using replace() function:

filename = filename.replace("special character to replace", "-")

answered Nov 1, 2019 at 15:03

Lio Ak's user avatar

In my case the error was due to lack of permissions to the folder path. I entered and saved the credentials and the issue was solved.

answered Sep 14, 2020 at 14:49

Nick Green's user avatar

Nick GreenNick Green

911 silver badge9 bronze badges

you should add one more «/» in the last «/» of path, that is:
open('C:Python34book.csv') to open('C:Python34\book.csv'). For example:

import csv
with open('C:Python34\book.csv', newline='') as csvfile:
    spamreader = csv.reader(csvfile, delimiter='', quotechar='|')
    for row in spamreader:
        print(row)

Charlie Joynt's user avatar

answered Jan 5, 2016 at 15:58

Hiep Tran's user avatar

Hiep TranHiep Tran

3,4821 gold badge21 silver badges27 bronze badges

3

Just replace with «/» for file path :

   open("description_files/program_description.txt","r")

answered May 24, 2018 at 7:21

P113305A009D8M's user avatar

P113305A009D8MP113305A009D8M

3141 gold badge4 silver badges12 bronze badges

1

In Windows-Pycharm: If File Location|Path contains any string like t then need to escape that with additional like \t

stderr's user avatar

stderr

8,4891 gold badge34 silver badges50 bronze badges

answered Apr 18, 2018 at 4:35

Abhijeet's user avatar

AbhijeetAbhijeet

8,3935 gold badges72 silver badges76 bronze badges

just use single quotation marks only and use ‘r’ raw string upfront and a single ‘/’

for eg

f = open(r'C:/Desktop/file.txt','r')
print(f.read())

Yu Hao's user avatar

Yu Hao

118k44 gold badges232 silver badges287 bronze badges

answered Mar 24, 2021 at 17:24

Anuragh Ragidimilli's user avatar

I had special characters like ‘‘ in my strings, for example for one location I had a file Varzea*, then when I tried to save (‘Varzea.csv’) with f-string Windows complained. I just «sanitized» the string and all got back to normal.

The best way in my case was to let the strings with just letters, without special characters!

answered Oct 22, 2022 at 1:24

Vinícius Junior's user avatar

For me this issue was caused by trying to write a datetime to file.

Note: this doesn’t work:
myFile = open(str(datetime.now()),"a")

The datetime.now() object contains the colon »’:»’ character

To fix this, use a filename which avoid restricted special characters. Note this resource on detecting and replacing invalid characters:
https://stackoverflow.com/a/13593932/9053474

For completeness, replace unwanted characters with the following:

import re

re.sub(r'[^w_. -]', '_', filename)

Note these are Windows restricted characters and invalid characters differ by platform.

answered Dec 1, 2022 at 18:58

Jacob Waters's user avatar

Jacob WatersJacob Waters

2671 gold badge2 silver badges10 bronze badges

for folder, subs, files in os.walk(unicode(docs_dir, 'utf-8')):
    for filename in files:
        if not filename.startswith('.'):
            file_path = os.path.join(folder, filename)

answered Jan 11, 2019 at 23:38

Prostak's user avatar

ProstakProstak

3,4757 gold badges34 silver badges46 bronze badges

In my case,the problem exists beacause I have not set permission for drive «C:» and when I change my path to other drive like «F:» my problem resolved.

answered Jan 14, 2019 at 12:25

Mohsen Hrt's user avatar

Mohsen HrtMohsen Hrt

2352 silver badges8 bronze badges

import pandas as pd
df = pd.read_excel ('C:/Users/yourlogin/new folder/file.xlsx')
print (df)

answered Mar 3, 2020 at 5:20

I Iv's user avatar

2

I got this error because old server instance was running and using log file, hence new instance was not able to write to log file. Post deleting log file this issue got resolved.

answered Nov 18, 2020 at 3:35

Abhishek Gaur's user avatar

When I copy the path by right clicking the file—> properties—>security, it shows the error. The working method for this is to copy path and filename separately.

answered Oct 6, 2022 at 0:48

Shui Cai Luo's user avatar

I had faced same issue while working with pandas and trying to open a big csv file:

wrong_df = pd.read_csv("D:Python ProjectsMLtitanic.csv")
right_df = pd.read_csv("D:Python ProjectsML\titanic.csv")

Martin Faucheux's user avatar

answered Dec 30, 2022 at 10:08

Sangeeta Kundu's user avatar

1

Содержание

  1. [Solved] OSError errno22 invalid argument
  2. What is OSError?
  3. What is errorno22 invalid argument?
  4. Example:
  5. ‘OSError : [errno22] invalid argument’ while using read_csv()
  6. ‘OSError : [errno22] invalid argument’ while using open()
  7. ‘OSError : [errno22] invalid argument’ while reading image using open()
  8. ‘OSError : [errno22] invalid argument’ while reading image using savefig()
  9. Q. What is oserror: (errno 22) invalid argument datetime?
  10. Q. What is oserror: (errno 22) invalid argument saving the file?
  11. TheCodeBuzz
  12. Python pandas OSError: [Errno 22] Invalid argument
  13. Python pandas OSError: [Errno 22] Invalid argument
  14. Issue Description
  15. Resolution
  16. Confusing error message «OSError: [Errno 22] Invalid argument» when incorrect filepath is specified for open #111
  17. Comments

[Solved] OSError errno22 invalid argument

An error is a problem in python incurred while compiling the code. For example, an error is raised when python cannot understand a given code because it failed to adhere to the syntax. There are several types of error in python, such as SyntaxError, RuntimeError, IndentationError, etc. OSError errno22 invalid argument is one such type of python error. We will first understand each of the components of the error separately.

What is OSError?

OSError is the type of error in OSError : [errno22] invalid argument. OSError is an error class for the OS module. It is a built-in exception in python, which is raised. It is raised when the error occurs due to some system failure. I/O failures also give rise to OSErrors.

When the disk is full, or the file cannot be found, OSError is raised. The subclasses of OSError are BlockingIOError, ChildProcessError, ConnectionError, FileExistsError, FileNotFoundError, etc. OSError itself is derived from the EnvironmentError.

What is errorno22 invalid argument?

As the name suggests, invalid argument errors occur when an invalid argument is passed to a function. If a function was expecting an argument of a particular data type but instead received an argument of a different data type, it will throw an invalid argument error.

Example:

The above code will raise invalid argument error.

The tf.reshape() function was expecting a tensor as an argument. But instead, it received 1 and 2 as the argument.

‘OSError : [errno22] invalid argument’ while using read_csv()

Read_csv() is a function in pandas which is used to read a csv file in python. We can read a csv file by accessing it through a URL or even locally. While reading a csv file using read_csv, python can throw OSError : [errno22] invalid argument error.

Let us try to understand it with the help of an example. The below code has been executed in python shell to access local files. First, we shall import the pandas file to use read_csv()

Now, we shall try to access a csv file.

The above line of code will raise the below error.

The reason behind the error is that python does not consider the backslash. Because of that, it showed oserror invalid argument. So what we have to do is that instead of a backslash, we have to replace it with a forwarding slash.

Th error has been resolved now.

‘OSError : [errno22] invalid argument’ while using open()

We can get OSError : [errno22] invalid argument error while opening files with the open() function. The open() function in python is used for opening a file. It returns a file object. Thus, we can open the file in read, write, create or append mode.

Let us understand the error by taking an example. We shall try to open a .txt file in read mode using open(). The file would be returned as an object and saved in variable ‘f’.

The code will throw the below error.

The OSError : [errno22] invalid argument error has been thrown because of the same reason as before. Here also, python fails to recognize the backslash symbol. On replacing backslash with forward slash, the error will be resolved.

‘OSError : [errno22] invalid argument’ while reading image using open()

The above error can appear while opening an image using the open() function even though the backslash character has been replaced with forward slash. Let us see the error using an example.

The error thrown would be:

This error mainly occurs because of the copying of the file path. The Unicode characters also get copied sometimes when we copy the file path from our local system or the internet.

The Unicode character, ‘u202a’ in the above example, is not visible in the file pathname. ‘u202a’ is the Unicode control character from left to right embedding. So, it causes the above oserror invalid arguments.

The solution to this is straightforward. We simply have to type the URL manually instead of copying it. Thus, the Unicode character will no longer be in the URL and the error will be resolved.

As seen above, initially the program was showing an error because the Unicode character was present even though it was not visible. But, the error gets resolved when the second time the same code was typed manually.

‘OSError : [errno22] invalid argument’ while reading image using savefig()

Savefig() function in python is used to save an image locally, which has been plotted using the matplotlib library. It is accessed using plt.savefig().

While using savefig() function, OSError : [errno22] invalid argument error can also occur. This error too occurs due to the same reasons as mentioned above. When we try to save the image file, we must ensure that the file is not saved with colons, brackets, or backslash.

Doing so will raise the oserror. Next, check if the file is not saved with those characters and remove them if they are present. This shall resolve the error.

Q. What is oserror: (errno 22) invalid argument datetime?

A. The datetime module in python is a module that is used for manipulating date and time. OSError: (errno 22) invalid argument datetime occurs when we are using fromtimestamp. Checking the units will solve the error.

Q. What is oserror: (errno 22) invalid argument saving the file?

A. The OSError: (errno 22) invalid argument occurs may also occur when one is trying to save a file. For example: adding an unnecessary semicolon to the filename also causes the error. It is because windows do not allow semi-colons in file names.

That was it for OSError: (errno 22) invalid argument. If you have anything to share, we would love to hear about it in the comments. Keep learning because you can never learn enough!

Источник

TheCodeBuzz

Best Practices for Software Development

Python pandas OSError: [Errno 22] Invalid argument

Python pandas OSError: [Errno 22] Invalid argument

Today in this article, we will cover below aspects,

Issue Description

Python Pandas CSV to JSON or JSON to CSV conversion causes below error,

OSError: [Errno 22] Invalid argument

Below is the sample code to reproduce the error,

Resolution

There could be multiple other issue causing this incompatibility.

Recently I got this error in the GCP cloud while using Pandas library to converting the data CSV to JSON format.

This issue may also be caused while using a large size of the file for conversion using the panda’s library. For me, the issue occurred for the 20Kb file size as well. So I am assuming it’s important that other related packages are also compatible with the panda’s library version used.

I was able to resolve the issue simply by using below upgrade command,

If you get any issue even with the above fix, Please use few below steps to resolve the issue,

  • Please try to use the requirements.txt orsetup.py file and specify the latest available pandas package.
  • Alternatively closing and opening the project could be helpful to reinstall any missing packages.

Did I miss anything else in these resolution steps?

Did the above steps resolve your issue? Please sound off your comments below!

Please bookmark this page and share it with your friends. Please Subscribe to the blog to get a notification on freshly published best practices and guidelines for software design and development.

Источник

Confusing error message «OSError: [Errno 22] Invalid argument» when incorrect filepath is specified for open #111

Issue Description:
When r2pipe is used to open a file, and the specified filepath is incorrect (i.e., points to a non-existent file), the stack trace doesn’t end with «Cannot open file». It instead ends with «OSError: [Errno 22] Invalid argument» and points to the error being in open_sync.py . This can be quite confusing when troubleshooting.

Code that throws error (test.py):

Even though the correct error is displayed right at the beginning, the OSError at the end is confusing when troubleshooting (because we tend to start from the last call and work our way up).

Environment:

OS:
Windows 10 64-bit

radare2:
radare2 4.3.0-git 23679 @ windows-x86-32 git.4.2.0-16-g04f065c68
commit: 04f065c68c35e49996dc138560e99489e0a45dcb build: 25/01/2020__ 8:31:33.55

r2pipe:
Version: 1.4.2

Python:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32

The text was updated successfully, but these errors were encountered:

Also encountering this issue, here is an example of r2pipe claiming my argument is invalid:

Here is me doing the same thing in radare2.exe

I’m on a Windows 10 Pro, 64-bit VM
Using radare2-5.3.0 and python 3.7.9

I gave it a try with the latest build from git, but got the same behavior.

I discovered that if I copy the file to the current dir AND take out the flags in the open, then it doesn’t get the error. For instance, this ran on my Windows VM without an error:

python3 -c «import r2pipe; r = r2pipe.open(‘brainpan.exe’); print(r.cmd(‘aaa’))»

I didn’t actually get any output from the print(r.cmd(‘aaa’)) for some reason but it did execute without an error.

I found that if I tried only taking out the flag, or only using the binary in the same path, I still got the error. I had to make sure to do both steps.

the command ‘aaa’ only prints to stderr, so its expected to not get any output from it.

Thanks for testing, i also noticed you used / instead of which is what i would expect from a windows path to contain. i think all those issues are in the python implementation of r2pipe.

Let me know if you want to go deep into the python module to add some prints here and there to determine what’s going on. The example you pasted works fine for me on linux and macos. So it’s windows and python specific issue :/

I’d be happy to take a crack at it, if you don’t mind helping me with specific places and things to test.

Regarding the /, yeah, I should have also mentioned I tried the normal Windows slashes but it thought it was an escape character:

Also, I have a radare2 functionality question but it’s not really a bug, so I’m not sure this thread is the place for it. Would you rather I open a new issue?

I’d be happy to take a crack at it, if you don’t mind helping me with specific places and things to test.

Regarding the /, yeah, I should have also mentioned I tried the normal Windows slashes but it thought it was an escape character:

Also, I have a radare2 functionality question but it’s not really a bug, so I’m not sure this thread is the place for it. Would you rather I open a new issue?

Yeah, because you are writing path in python code. Have you tried double backslashes \ or to use single backslashes in a raw Python string like r’C:UserssordidlistDesktopbrainpan.exe’ ?

Can confirm it works if I escape the backslashes like \ , and also if I use r’string’ . I’ve used byte strings in python before but I didn’t know about raw strings, that’s cool.

So it’s a no-issue? 😀

The only other thing is the flags=[‘-A’] thing but the workaround of doing r.cmd(‘aaa’) works just fine for me. I’ll re-test the flags issue with the binary in the local dir later today but as I recall, that didn’t work on Windows.

If you’ve got bigger bugs to squash, I’m okay with closing this issue.

There are always bugs to fix in r2land, but that’s not a reason to close the issue, it should be fixed. but i can only attempt blind fixes because i dont have or use windows, if the issue is only with -A now, i have an idea about where could be the bug. If so, i can send you a link to the last r2 for windows with that fix (when i push it) and you can confirm the fix?

Источник

When I am trying to open a html file with read mode in python spyder I am getting the following error
[Errno 22] Invalid argument

Posts: 7,842

Threads: 148

Joined: Sep 2016

Reputation:
572

please, post your code in code tags as well as full traceback in error tags.

Posts: 6

Threads: 2

Joined: Sep 2017

Reputation:
0

Sep-27-2017, 08:00 AM
(This post was last modified: Sep-27-2017, 08:12 AM by buran.)

code:

# -*- coding: utf-8 -*-
"""
Created on Wed Sep 20 07:44:11 2017

@author: Srinu
"""
f=open('E:baby2008.txt','r')

Error:

Error:

OSError: [Errno 22] Invalid argument: 'E:x08aby2008.txt'

User has been warned for this post. Reason: No BBcode, not following instructions

Posts: 6,572

Threads: 116

Joined: Sep 2016

Reputation:
487

b is an escape characters,never use single in a path.
Turn around/,double up or raw string all work.

>>> s = 'baby'
>>> s
'x08aby'

# Other way
>>> s = '/baby'
>>> s
'/baby'

# Double up
>>> s = '\baby'
>>> s
'\baby'

# Raw string
>>> s = r'baby'
>>> s
'\baby'

Posts: 7,842

Threads: 148

Joined: Sep 2016

Reputation:
572

Sep-27-2017, 08:16 AM
(This post was last modified: Sep-27-2017, 08:17 AM by buran.)

you are on Windows, that uses backslash as path separator However for python this is escape char, so you need to use forward slash or raw string or escape the backslash. In addition you should use with context manager when open the file. It will close the file for you at the end (something you don’t do in your code)

with open('E:/baby2008.txt','r') as f:
# do something here
with open(r'E:baby2008.txt','r') as f:
# do something here
with open('E:\baby2008.txt','r') as f:
# do something here

Posts: 6

Threads: 2

Joined: Sep 2017

Reputation:
0

wonderful … It’s working. Thanks a ton

Posts: 2

Threads: 0

Joined: Feb 2020

Reputation:
0

Hi guys, I am having the same issue as the original poster. I have tried to use the suggested methods to deal with it and they don’t seem to be working.

Here is my code:

#load in ENSO data
enso = pd.read_excel(r'‪C:UsersEli TDesktopENSO.xlsx', 'r')

Error message:
OSError: [Errno 22] Invalid argument: ‘u202aC:\Users\Eli T\Desktop\ENSO.xlsx’

Posts: 6,572

Threads: 116

Joined: Sep 2016

Reputation:
487

Feb-11-2020, 03:01 PM
(This post was last modified: Feb-11-2020, 03:02 PM by snippsat.)

Look like your editor have introduced a non-printing character U-202A is LEFT-TO-RIGHT EMBEDDING.
It’s there even if you can not see it,this is a copy of code from your post.

>>> s = r'‪C:UsersEli TDesktopENSO.xlsx'
>>> s
'u202aC:\Users\Eli T\Desktop\ENSO.xlsx'

A temp fix could be this,you should investigate editor,eg try and other and see if it’s happen there to.

>>> s = r'‪C:UsersEli TDesktopENSO.xlsx'
>>> s
'u202aC:\Users\Eli T\Desktop\ENSO.xlsx'
>>> 
>>> s = s.lstrip('u202a')
>>> s
'C:\Users\Eli T\Desktop\ENSO.xlsx'
>>> enso = pd.read_excel(s, 'r')

Posts: 2

Threads: 0

Joined: Feb 2020

Reputation:
0

Feb-11-2020, 03:24 PM
(This post was last modified: Feb-11-2020, 03:24 PM by LOVESN.)

That did work for the most part. When I get to the end where I try to read in the file though, it says:

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\Eli T\Desktop\ENSO.xlsx’

Edit: Actually this worked, I made an error on my end. Thanks!!

Posts: 1

Threads: 0

Joined: May 2020

Reputation:
0

May-18-2020, 10:51 PM
(This post was last modified: May-18-2020, 10:51 PM by tdandwa.)

(Feb-11-2020, 03:24 PM)LOVESN Wrote: That did work for the most part. When I get to the end where I try to read in the file though, it says:

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\Eli T\Desktop\ENSO.xlsx’

Edit: Actually this worked, I made an error on my end. Thanks!!

that has worked!

Понравилась статья? Поделить с друзьями:
  • Intouch ole automation error 0x100e0202
  • Intex e81 ошибка
  • Interrupted 1 error during collection
  • Internetqueryoption error 12178
  • Internet неопознанная сеть как исправить