Skip to content
Advertisement

Tag: path

Add directory to PATH inside a Python script such that a third-party module can find a DLL with ctypes find_library

Let’s say a third-party module moduleXYZ.py (that I don’t want to fork/modify) does: In my code main.py I’m importing it with This DLL is in C:Program Filesgsgs9.56.1bin which is not in my global system path. Question: how to add this directory to the path (for the duration of the script run, not permanently for the system) from inside my script

How to migrate all packages, settings, user data etc. after updating to a newer Python version?

I’ve just installed Python 3.10 on Windows 10 and none of my scripts are working. For instance, when doing jupyter notebook I get I’ve been using Python 3.9 and all the scripts are still located in C:Program FilesPython39Scripts. However, there is nothing in C:Program FilesPython310Scripts (besides pip). As a first attempt to solve the problem, I uninstalled Python 3.10 leaving

Location for Python version on macOS (using universal-installer for 3.10.5)

My very first post here, as new comer to MacOS and Python. Recently installed python 3.10.5 via macOS 64-bit universal2 installer .pkg file downloaded from python.org > Downloads > mac OS on MacOS 12.4 [M1/Apple Silicon]. In terminal, the command python3 shows the version as 3.10.5. But echo $PATH is giving me a path leading to /Library/Frameworks/Python.framework/Versions/3.10/bin I was expecting

Accessing script file location from an external file python

I have the following bizarre set up. Consider 3 scripts in different directories: root1/folderA/scriptA.py root2/folderB/scriptB.py root2/folderC/scriptC.py The first file and it’s location are fully modifiable. The second and third are completely fixed. scriptA.py contains a parent class: scriptB.py contains a child class: scriptC.py contains the code to execute: In scriptC.py what I want is the behaviour to get the path

Import functions from another directory

I am running a python script (app.py) where I have to use two functions from another script (src.py), located inside another directory. The structure is the following: I am using, in app.py, the following lines: to access to the functions odd_all, even_all declared inside src.py. However, I get the error: ModuleNotFoundError: No module named ‘src’. How could I solve this

All possible combinations of a list of tuples

I’m creating “Boggle” in python, and I have a list of tuples that represent coordinates on a game board: I’m trying to create a new list of lists of tuples that will represent all possible paths on the board. It’d look something like this: I tried using itertools.combinations and itertools.permutations but it doesn’t seem to do the job, for example

When import a python file into another (in a subdirectory) it stops finding the csv in the same directory

I’m trying to import the cleaning file in the managers file like this: The main folder contains the files cleaning, transaction listing and a sub folder called “apps” with the managers file: Also note that the cleaning file reads the transaction listing.csv file. The issue I’m getting when running is: And “Transaction Listings.csv” is correctly loaded by cleaning but no

Advertisement