sys.path

Conda environment using incorrect module because of order os sys.path

Conda environment using incorrect module because of order os sys.path Question: I am using conda version 4.14.0. When I activate a conda environment I can see that the current numpy module is 1.22.3 conda list | grep -i numpy numpy 1.22.3 py39hc58783e_2 conda-forge When I run python in the conda environment and load numpy it …

Total answers: 1

PYTHONPATH works in interactive mode but fails in script

PYTHONPATH works in interactive mode but fails in script Question: Problem I’ve been trying to run a python script which imports from the Foundation package: from Foundation import … Whenever I try to run this I get the following error: Things I’ve done: I’ve installed the Foundation package and verified that it was installed in …

Total answers: 1

How to add a path to the system path in MySQL Workbench for Mac (Big Sur)

How to add a path to the system path in MySQL Workbench for Mac (Big Sur) Question: I was using Catalina OS with MySQL Workbench for Mac, which worked fine for old iMac of mine. But when I recently bought a new Mac with Big Sur OS and installed MySQL Workbench, it gave me the …

Total answers: 3

Get parent of current directory from Python script

Get parent of current directory from Python script Question: I want to get the parent of current directory from Python script. For example I launch the script from /home/kristina/desire-directory/scripts the desire path in this case is /home/kristina/desire-directory I know sys.path[0] from sys. But I don’t want to parse sys.path[0] resulting string. Is there any another …

Total answers: 10

Pylint – How to print Pylint's sys.path?

Pylint – How to print Pylint's sys.path? Question: I’m attempting to add modules to my Pylint path so they can be imported by using the solution as seen in this question. Unfortunately, the modules I expect should be available for import after using this solution still don’t seem to be there. I want to check …

Total answers: 1

Permanently adding a file path to sys.path in Python

Permanently adding a file path to sys.path in Python Question: I had a file called example_file.py, which I wanted to use from various other files, so I decided to add example_file.py to sys.path and import this file in another file to use the file. To do so, I ran the following in IPython. import sys …

Total answers: 4

PYTHONPATH vs. sys.path

PYTHONPATH vs. sys.path Question: Another developer and I disagree about whether PYTHONPATH or sys.path should be used to allow Python to find a Python package in a user (e.g., development) directory. We have a Python project with a typical directory structure: Project setup.py package __init__.py lib.py script.py In script.py, we need to do import package.lib. …

Total answers: 6