Linked Questions
84 questions linked to/from Permanently add a directory to PYTHONPATH?
0
votes
1
answer
666
views
Custom modules import without typing folder name? [duplicate]
I have a folder called Python Modules which contains single-file modules I've made that I often use, for example one called mytimer.py. I added Python Modules to my Windows PYTHONPATH environment ...
0
votes
0
answers
349
views
Python 3, sys.path doesn't work, how to permenantly append a path? [duplicate]
Firstly, I am using Fedora 20, Python3.3
Basically everytime I have to use any python libraries I have to use:
sys.path.append('/usr/lib/python3.3/site-packages/')
This is getting to be a real ...
1871
votes
38
answers
1.6m
views
How can I import a module dynamically given the full path?
How do I load a Python module given its full path?
Note that the file can be anywhere in the filesystem where the user has access rights.
See also: How to import a module given its name as string?
1880
votes
36
answers
2.2m
views
Relative imports in Python 3
I want to import a function from another file in the same directory.
Usually, one of the following works:
from .mymodule import myfunction
from mymodule import myfunction
...but the other one gives ...
2268
votes
18
answers
1.9m
views
How to reload .bashrc settings without logging out and back in again?
If I make changes to .bashrc, how do I reload it without logging out and back in?
89
votes
23
answers
245k
views
Installing OpenCV for Python on Ubuntu, getting ImportError: No module named cv2.cv
I have an Ubuntu 14.04 system, on which I want to install OpenCV and use it with Python 2.x.
I installed OpenCV using the instructions here:
https://help.ubuntu.com/community/OpenCV
The install ...
138
votes
9
answers
81k
views
PEP8 – import not at top of file with sys.path
Problem
PEP8 has a rule about putting imports at the top of a file:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and ...
87
votes
5
answers
320k
views
Python Library Path
In ruby the library path is provided in $:, in perl it's in @INC - how do you get the list of paths that Python searches for modules when you do an import?
27
votes
5
answers
21k
views
Module name different than directory name?
Let's assume I have a python package called bestpackage.
Convention dictates that bestpacakge would also be a directory on sys.path that contains an __init__.py to make the interpreter assume it can ...
21
votes
4
answers
76k
views
How to check that the anaconda package was properly installed
I'm completely new to Python and want to use it for data analysis. I just installed Python 2.7 on my mac running OSX 10.8. I need the NumPy, SciPy, matplotlib and csv packages. I read that I could ...
14
votes
5
answers
33k
views
How to use wxPython for Python 3?
I installed wxPython 3.0.1.1, but I'm unable to import wx using Python 3.4.1. I am getting the following error:
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build ...
3
votes
5
answers
25k
views
Importing Self Written Python Module
I've read through many of the other S-O questions relating to this, but still am having trouble getting it to work for me. Apologies in advance for the overlap! I'm using python 2.7.10, on Windows 7....
7
votes
1
answer
50k
views
How to import a single function to my main.py in Python from another module? [duplicate]
In my script I have a function inside a module which I wish to be able to use in my main module to prevent redundancy. This other module (not my main, let's call it two.py) contains several classes ...
12
votes
3
answers
8k
views
Importing From Sister Subdirectories in Python?
So, I've seen a few similar questions on Stack Overflow, but nothing seems to address my issue, or the general case. So, hopefully this question fixes that, and stops my headaches. I have a git repo ...
Eli's user avatar
- 39.3k
5
votes
5
answers
16k
views
python3.x : ModuleNotFoundError when import file from parent directory
I am new to Python. This really confused me!
My directory structure is like this:
Project
| - subpackage1
|- a.py
| - subpackage2
|- b.py
| - c.py
When I import ...