Questions tagged [python-os]

The Python os module provides a portable way of using operating system dependent functionality. Use this tag for questions about using the "os" module.

The Python os module provides a portable way of using operating system dependent functionality.

Links

551 questions
-2
votes
2 answers

What does os.system return and how can I convert its output?

I am new to the os library, and while experimenting with decoding QR codes and extracting only the meaningful part of the output, I received this error: AttributeError: 'int' object has no attribute 'replace' At first glance I thought that I should…
Feres Hammemi
  • 29
  • 1
  • 1
  • 6
-2
votes
2 answers

How to get python script file path that has been compiled in binary .exe?

I have python script myscript.py that I compiled with pyinstaller with the following command: pyinstaller -F myscript.py . Now I get a file called myscript.exe . In my script, there are line that I wrote to get the path of this file using the…
TSR
  • 17,242
  • 27
  • 93
  • 197
-2
votes
1 answer

Getting error regarding "os" module of python

I am using python2.7 on ubuntu system. I am getting following errors while working with "os": AttributeError: 'module' object has no attribute 'fsencode' On this line: directory=os.fsencode(indir) I have checked other solutions but they are not…
-3
votes
1 answer

Which Module do I use In python to browse, Copy and paste Files in Directories

I want to add a function in my program that when called , opens a browsing window like ones that open when you click on browse to change directory location in a setup. I want it to let me browse through directories , select a file and when I select…
-3
votes
2 answers

How to make a csv file with one column as file name and other as folder name

I am making a dataset, which is in a way such that for one thing like "apple" there is a folder named "apples" in the root folder(contains multiple folders) that contains only images of apples and so on. I want to make a csv file in which it has all…
vikrant
  • 3
  • 3
-3
votes
1 answer

Most efficient way to check if a string contains any file format?

I have a .txt with hundreds of thousands of paths and I simply have to check if each line is a folder or a file. The hard drive is not with me so I can't use the module os with the os.path.isdir() function. I've tried the code below but it is just…
-3
votes
2 answers

Dealing with lists in a dictionary

I am iterating through some folders to read all the objects in that list to later on move the not rejected ones. As the number of folders and files may vary, basically I managed to create a dictionary where each folder is a key and the items are the…
-3
votes
1 answer

Error : 'str' object has no attribute 'system'

It looks like os.system() error.I dont know what to do next. #!/usr/bin/env python # -*- coding:utf-8 -*- import re, platform, os def init(): cmd = { 'centos': 'yum -y install python-devel && pip install psutil >…
-3
votes
2 answers

Splitting Python shall command using os

I am writing code on python which is calling the log file VXT_CDR_1_1_20180816.DAT using os.system(command) The code is here import os command = "cat /home/smslog/CDRS/VXT_CDR_1_1_20180816.DAT | awk -F'|' '{print $3}' |sort|uniq" output=…
bill
  • 118
  • 5
-4
votes
2 answers

how to i get os.listdir with follow the file?

enter image description here enter image description here Hello, I have encountered a problem. When I use os.listdir, I hope that the effect of picture 1 will appear, but the effect of python is reversed. I would like to ask how can I get the data…
-4
votes
1 answer

Python - OS Module 'TypeError: 'bool' object is not iterable''

I Was trying to make a checker with the OS module for the directory lib, and it raised a error, the full error log is for folder in path.exists('./lib'): TypeError: 'bool' object is not iterable the code is for folder in path.exists('./lib'): …
Raphiel
  • 398
  • 2
  • 17
1 2 3
36
37