For questions about importing modules in Python
0
votes
1answer
21 views
Print variable from other file with raw_input
So I'm just starting out on a project here. For starters, I have two files.
The first file is myDict.py. In there I store variables that I want to be able to fetch.
myDict.py:
numbers = [1, 5, 8, ...
0
votes
0answers
9 views
Linting .py files run-time as they are loaded in Python
Does CPython interpreter provide any hooks to grab and inspect .py source files as they are being loaded?
I was thinking if PEP 666 http://www.python.org/dev/peps/pep-0666/ could be implemented with ...
1
vote
0answers
21 views
Keeping Python packages with the same top-level name in different directories
I have several Python packages that I'd like to keep on separate filesystems but which unfortunately share the same top-level module name.
To illustrate, the directory structure looks like this:
...
0
votes
1answer
18 views
Python Module Imports
I am importing a module
from Boards import CheckerBoardModule
CheckerBoardModule includes a class called CheckerBoard
When I want to use it, I need to call CheckerBoardModule.CheckerBoard, rather ...
0
votes
2answers
7 views
py2app ImportError with watchdog
I am attempting to use py2app to bundle a small Python app that I've made in Python 2.7 on Mac. My app uses the Watchdog library, which is imported at the top of my main file:
from watchdog.observers ...
0
votes
2answers
38 views
Python: Running a strip of code unless imported
I have a file that I'm importing into my program (say a file with dictionaries). At the beginning of this file I want to put a strip of code which prints that this is not the main file and then ...
20
votes
3answers
382 views
Why does it take longer to import a function from a module than the entire module itself?
Consider:
>>> timeit.timeit('from win32com.client import Dispatch', number=100000)
0.18883283882571789
>>> timeit.timeit('import win32com.client', number=100000)
0.1275979248277963
...
0
votes
1answer
24 views
Jenkins runs imported python script before main python script
I have a main build script which every jenkins job executes. This main script gets the job name(from Jenkins) and then executes the relevant script for that job name. Right now, I'm using ...
1
vote
1answer
47 views
Difference between Numpy and Numpy-MKL?
I wanted to test some signal processing and statistics using SciPy.
So I had to use scipy.signal and scipy.stats, but I always used to get an error:
ImportError: DLL load failed: The specified module ...
1
vote
1answer
24 views
Select a module using importlib and use in multiprocessing functions
I'd like to select in my main function which module to import based on an argument passed to the Python script. So, I'm using one of
blah = importlib.import_module("blah1")
blah = ...
0
votes
1answer
21 views
ImportError when importing certain modules from SciPY
I have used Scipy for some time. This is the first time I am using it for Signal processing!
But when I import modules like
from scipy import signal
from scipy import special
I get the error:
...
0
votes
2answers
49 views
ImportError: No module named statsmodels.api
I'm new in python and have this problem. I have install Pandas, Numpy, Scipy, and I install Stats Models with apt-get install python-statsmodels, but when I try to use:
import statsmodels.api as sm
...
1
vote
1answer
37 views
“import numpy” tries to load my own package
I have a python (2.7) project containing my own packages util and operator (and so forth).
I read about relative imports, but perhaps I didn't understand. I have the following directory structure:
...
2
votes
2answers
47 views
Accessing Python's “print” function from the globals dictionary
Apologies in advance for conflating functions and methods, I don't have time at the moment to sort out the terminology but I'm aware of the distinction (generally).
I'm trying to control what ...
0
votes
1answer
18 views
update module on import to python interpreter
In short
How to force python interpreter to load the most up-to-date code version of my module everytime I make some changes in the module code?
Or at least reload the last modified version by ...
1
vote
1answer
30 views
Can't import module from library
I have a script that requires two other modules to be loaded from another folder in the same directory as the script.
In the main script I have the line:
from modules import *
But I keep getting ...
1
vote
2answers
70 views
Python : How to access file from different directory
I have the following project structure
SampleProject
com
python
example
source
utils
ConfigManager.py
conf
...
5
votes
1answer
67 views
How can one Python module break another?
After several hours of debugging and trial and error, I found that importing two independent Python modules caused a function in one of them to stop working.
import arcpy
# works
sde_conn = ...
0
votes
0answers
29 views
Using sys.meta_path
Please help me with this problem .
I have a test platform written in python and seek to make a kind of "personal
developement space "- I will call it in the bellow text as PDS.
Basically it should ...
0
votes
1answer
42 views
How to temporarily modify sys.path in Python?
In one of my testing scripts in Python I use this pattern several times:
sys.path.insert(0, "somedir")
mod = __import__(mymod)
sys.path.pop(0)
Is there a more concise way to temporarily modify the ...
0
votes
1answer
22 views
Multiple imports in python as the same keyword
I am more or less a python noob and while getting my hands dirty, in one of the modules I am using, I encountered this statement:
from django.utils.translation import ugettext, ugettext_lazy as _
...
-2
votes
2answers
64 views
reload/reimport a file/class that is imported using from * import *
well, as the title say, i got a group of import, all import a class, all in the same folder as the script running it:
from lvl import lvl
from get import get
from image import image
from video import ...
0
votes
0answers
43 views
Script runs in spite of an unresolved import error in Eclipse PyDev, but stops running if the error is fixed… O_o
I'll try to be as clear as possible:
This is my project structure:
PYDEV PROJECT FOLDER
src folder
package
module1
module2
1 - In module1 I say:
import ...
1
vote
0answers
30 views
Importing standard modules in ironpython script in silverlight application raises an error
Can someone explain, please, how to avoid errors of type: "ImportError: No module named nameOfModule"
in ironpython script, which is part of Silverlight web application?
The error pops, even when I ...
1
vote
0answers
20 views
Safest way to modify .pyc compilation/loading workflow?
I'm working on MacroPy, and one of the things the project does is hook into the Python import system via PEP302 import hooks. However, one thing that I have not done (and would like to do) is to have ...
0
votes
1answer
29 views
Script won't run in order
I have this python script that will not run in the correct order I want it to. Here is the code:
import VT as vt
import VT_Tests
import AUTO as auto
def main():
auto.run()
vt.run()
if ...
2
votes
2answers
40 views
Import * include submodules
I have a directory structure that looks like this:
scripts/
__init__.py
filepaths.py
Run.py
domains/
__init__.py
topspin.py
tiles.py
hanoi.py
...
1
vote
1answer
37 views
Python: Importing parent and child classes from different modules
I have a parent class in one file, a child class in another, and I'm trying to use them in a third. Sort of like this:
test1.py
class Parent(object):
def spam(self):
print "something"
...
1
vote
2answers
37 views
Python complex subpackage importing
I have a pretty complex package tree like the following within yet another package
A\
B\
a.py
b.py
c.py
C\
a.py
b.py
c.py
I want to be able ...
1
vote
1answer
40 views
Issue with import path in Python 3
I'm having an issue with the import statement in Python 3. I'm following a book (Python 3 Object Oriented) and am having the following structure:
parent_directory/
main.py
ecommerce/
...
2
votes
1answer
56 views
Overlapping Python import statements - bad practice?
Frequently in my Python utilities I need to use os.path, and a convention I've gotten into is importing it as:
import os.path as fs
fs being my abbreviation for "file system."
I'm writing a utility ...
0
votes
2answers
31 views
Python: Importing from a running instance, or an alternative
I have 2 files, data.py and interpret.py.
data.py:
X = cPickle.load(open("X","r"))
interpret.py:
from data import X
query = raw_input("Enter query")
#do something with query and X
Object X ...
0
votes
2answers
33 views
python path import collision
I have a Python application that has the following directory structure:
/home/vagrant/app
/home/vagrant/app/support
/home/vagrant/app/utils (1)
/home/vagrant/app/examples/example_a
...
1
vote
4answers
54 views
Can't import module from bin directory of the same project
I'm building a library that will be included by other projects via pip.
I have the following directories ('venv' is a virtualenv):
project
\- bin
\- run.py
\- myproj
\- __init__.py
...
3
votes
3answers
61 views
Import all classes (or functions) in all files in folder, as if they were all in the __init__ file
I have a folder with multiple files containing a lot of different classes. These could all be in one big file but for the sake of making it a bit easier to read I've split it up in multiple files ...
0
votes
0answers
25 views
Nice way to package wide set up standard output streams in Python
As an example there is a project/package with several modules.
The goal is to achieve the same standard stream output handling behaviour for every file.
Let us suppose that this is a command line ...
0
votes
1answer
102 views
Python 3 lxml ImportError on CentOS 6.4 [duplicate]
CentOS 6.4 on my desktop had python 2.6.6 already installed
$ which python
/usr/bin/python
$ python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on ...
1
vote
0answers
36 views
Cannot import module when using memory_profiler
I'm trying to use memory_profiler, but I run into a problem that is isolated in example.py:
#! /usr/bin/env python
import argparse
def parse_args():
parser = ...
8
votes
2answers
109 views
How to prevent multiple initialization of dynamic library
I am working on Python version 2.7.
I have a module extension for Python written in C.
The module initialization function PyMODINIT_FUNC initmymodule contains some code for initializing OpenSSL ...
1
vote
1answer
47 views
Nested module and package imports in Python
We have a VERY large python project (200+ files)
and up till now I've been handling it dependencies very well there are a few spots where some new part of the project used and existing part from ...
1
vote
1answer
27 views
ImportError with VirtualEnv
I'm trying to use VirtualEnv for a Flask app that I'm creating since everyone has recommended me to do so. After creating my virtual environment, I installed the libraries that I needed using pip ...
2
votes
1answer
48 views
Python cross-module globale variable
I'm new to Python and I was trying out nose as a unit test framework.
I came across a behavior I didn't expect, but maybe this is normal, hence my question.
I have two (very basic) files:
...
0
votes
0answers
106 views
Python3 can not find module xmlrpc from unittests
I am working on a python project with 2 other people, but I can't run our tests. When I run the tests using python3 -m unittest I get this output
Traceback (most recent call last):
Traceback (most ...
0
votes
1answer
55 views
Hide external modules when importing a module (e.g. regarding code-completion)
The title is probably pretty bad and I'm sure something similar has been asked before, but I could not find a solution for this (also I'm new to python…).
I have several modules in one package (a ...
2
votes
1answer
77 views
Should __init__.py also contain python module imports?
When writing your own package in Python, should __init__.py contain imports like os, sys? Or should these just be imported within the file that is using them?
2
votes
5answers
101 views
Trouble importing the correct module in python in GAE
How do I explicitly tell Google App Engine (python) to import json from the python standard libraries?
Due to a poorly named file (that I can NOT change or rename at this time) I am having trouble ...
1
vote
1answer
231 views
python - importError: no module named pysphere
I am able to type the following into python.exe to create a session to Vmware Esxi
from pysphere import VIServer
server = VIServer()
server.connect("myserver", "user", "password")
When I save the ...
0
votes
1answer
71 views
Django import error - bad argument to internal function
I'm making a basic time-card program. I'm getting an error while importing views from urls.py. The other files in the app (models, forms, etc) can be imported, but any call to import views returns an ...
0
votes
1answer
69 views
Ice in Python - unresolved import IcePy in generated interfaces
I'm trying to use Ice (version 3.4.2) in Python (2.7.3). When I generate content using slice2py I get a class with the following import statement
import Ice, IcePy, __builtin__
The problem is, ...
0
votes
1answer
124 views
“Unused wild import”: Why?
Whenever I import from another module using an asterisk (from import *) I am fined with an "unused wild import"-warning. It appears as if this is not the right way to do the import, but why does that ...