1

I am trying to run a python script on a linux server and it needs to access a list on a text file - saved in the same location that I'm running the script.

This might be just a simple formatting issue but I've tried various ways and still no luck.

Here is the code in my python file:

list1 = session.target_list("C:\\root\\instapy-quickstart\\apples.txt")
session.follow_by_list(list1)

Getting the error:

No such file or directory: C:\root\instapy-quickstart\apples.txt
Pat. ANDRIA
2,4401 gold badge16 silver badges31 bronze badges
asked Nov 14, 2020 at 11:27
2
  • path is wrong, on linux server it'll look something like /home/your_user/file.txt. Alternatively, you can specify file location relative to the place you're running your script from, like ./apples.txt Commented Nov 14, 2020 at 11:32
  • You should always use raw string litterals when using backslashes: session.target_list(r"C:\root\instapy-quickstart\apples.txt") - note the r before the quote. Or just use forward slashes, even on Windows. Commented Nov 14, 2020 at 11:35

1 Answer 1

1

If the file is in the same location, why you don't use the name of the file without pathway? I mean:

list1 = session.target_list("apples.txt")
answered Nov 14, 2020 at 11:37
Sign up to request clarification or add additional context in comments.

1 Comment

@mattygee happy to hear that :).

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.