How to get the complete path of directory in python? [duplicate] - python-3.x

This question already has answers here:
How to get an absolute file path in Python
(11 answers)
Closed 7 months ago.
I have directory '/batchjobs/files/'. I want to know the complete path of it.

You can use the pathlib library.
import pathlib
print(pathlib.Path('/batchjobs/files/').absolute())

Related

With the bpython shell, how do I preload imports when the shell starts up? [duplicate]

This question already has answers here:
Automatically import models on Django shell launch
(2 answers)
Automatically import modules when entering the python or ipython interpreter
(9 answers)
Closed 1 year ago.
I'm using Django 3.2, Python 3.9 and bpython==0.21 for a more useable shell. However, I notice when I start using my shell, I always have to run the same import commands
$ python manage.py shell
>>> from cbapp.models import *
>>> from cbapp.services import *
I like the bpython shell and would prefer to continue to use it, but is there a way that the imports can be run prior to the shell loading so I don't have to type (or scroll to) them each time?

Installing Pygame with "Requirement already satisfied" [duplicate]

This question already has answers here:
Cannot install pygame in Pycharm
(1 answer)
pycharm doesn't recognize pygame package
(2 answers)
Closed 2 years ago.
I am trying to install Pygame using Pycharm, but keep getting an error when downloading. It suggests running the command in the terminal, but when I do that it says:
Requirement already satisfied: pygame in /Library/Python/2.7/site-packages (1.9.6)
I don't understand what I am supposed to do at this point so some help would be really nice.

How to install filedialog package? [duplicate]

This question already has answers here:
Python module not found even though "Requirement Already satisfied in Pip"
(12 answers)
Closed 3 years ago.
I Can't able install filedialog package in python3 it shows already requirement satisfied. The package is installed but not working. Can anyone help me to solve?
You can use Tkinter's askopenfilenames. This is very similar to FileDialog, but with the Tkinter module.
import tkinter
from tkinter import askopenfilenames
root = tkinter.Tk().withdraw()
files = askopenfilenames() #This is the FileDialog window

How to import a file that starts with numbers (227exercise.py)? [duplicate]

This question already has answers here:
What are the requirements for naming python modules?
(3 answers)
Closed 4 years ago.
I tried to import the file 227exercise.py, but keep getting following error:
SyntaxError: Invalid Syntax
You can do this with importlib.
import importlib
module = importlib.import_module("227exercise")
print(repr(module))
# <module '227exercise' from '/home/ubuntu/227exercise.py'>
However, it is still strongly recommended that you name your python files with valid identifiers (they can't begin with digits).

python - How do I properly install suds-jurko? [duplicate]

This question already has answers here:
suds install error: no module named client
(8 answers)
Closed 7 years ago.
Let me just get this out of the way - I'm new to just about everything about modules. I can just about guarantee I'm going to say or ask something stupid.
To the point - I need to do some autotask API magic, and to do so I need to make use of suds-jurko (since I'm running Python 3.4 and suds is outdated).
I've installed it through py -m pip install suds_jurko which gave me an .egg, which I used easy_install on. Still, no sign of suds_jurko to be found.
Why can't I import suds-jurko, and why does it not show up in the help>>modules of IDLE?
Look here. The import statement for suds-jurko is still import suds.

Resources