FAQ Database Discussion Community


Generic python module

python,generics,python-module
I have a set of python modules that share most of the code with the unique difference of the class they are instantiating. I thought I could implement a template and render the module with the class I want to instantiate every time, but I reckon this is not the...

How to use remote python modules

python-3.x,python-import,python-module
How I can use some 'extra' python module which is not located localy but on a remote server? Somthing like using maven dependencies with Java

Python custom module installalation won't copy static files

python-2.7,setuptools,python-module,pypi
hi I'm developing a python module and when I create the install package using python setup.py sdist bdist_egg all the files are included on the zip file, but when I run python setup.py install all files are copied except the static files. the full project is on: https://github.com/efirvida/python-gearbox my setup.py...

Python: is there a way to use “unimported” objects in function definitions?

python,function,namespaces,python-module
I'm modifying a simple recursive function to draw a dragon curve using turtle: def draw_dragon(t, order, size, L=turtle.left, R=turtle.right): """ Draw a dragon curve """ if not order: t.forward(size) return size /= 1.41421 t.R(45) draw_dragon(t, order-1, size, L, R) t.L(90) draw_dragon(t, order-1, size, R, L) t.R(45) if __name__=="__main__": import turtle...

“site” is not a package

python,python-3.x,python-module
I have this directory structure: my_project/ site/ __init__.py app.py main.py main.py contains this: import site.app print('Success') Get this error: Traceback (most recent call last): File "main.py", line 1, in <module> import site.app ImportError: No module named 'site.app'; 'site' is not a package Renaming "site" to any other name, this works...

Python maximum recursion depth exceeded when installing a module

python,boto,python-module,python-install
I got maximum recursion depth exceeded when installing gcs-oauth2-boto-plugin-1.4 on my mac. I downloaded and unzipped the package, ran sudo python setup.py install under the installation directory, pretty standard stuff that you would do when install a Python module. I was doing it in a virtual environment (virtualenv). I did...

Module importing in python 2.7

python,django,python-2.7,path,python-module
this is my first post and I've been working with python for about a month now. Anyway I've been trying to import downloaded modules into python 2.7, such as django and mechanize, and I keep getting the same error telling me there is no such module. I downloaded both with...

Python import doesn't work when file is imported

python,python-3.4,python-import,python-module
I am having difficulties to understand how the python importer works.. I have a python script (fractalDimension.py) that imports a submodule ("greedyColoring.py") using: from boxCovering.greedyColoring import * It works fine when I call it directly: python fractalDimension.py The problem began when I moved the script to a folder and added...

How do variables inside python modules work?

python,module,python-module
I am coming from a Java background with Static variables, and I am trying to create a list of commonly used strings in my python application. I understand there are no static variables in python so I have written a module as follows: import os APP_NAME = 'Window Logger' APP_DATA_FOLDER_PATH...

Confused about how to import from other directories / parent directories within module (python 3)

python,python-import,python-module,pythonpath
First off, I know there are a number of questions related to this one already asked here (This and This seem most similar). I've read through a number of them, but am finding myself still very confused about the appropriate way to accomplish this. I have a project that I'm...

Python: Unexpected ImportError

python,python-module
I have these modules and packages: main.py/ pkg1/ __init__.py maclasse1.py pkg2/ __init__.py maclasse2.py main.py: from pkg1 import maclasse1 from pkg2 import maclasse2 if __name__=="__main__": MC1=maclasse1.MaClasse1() MC1.ma_classe1() MC2=maclasse2.MaClasse2() MC2.ma_classe2() maclasse1.py from pkg2 import maclasse2 class MaClasse1: def ma_classe1(self): print "Ma Classe 1" c2=maclasse2.MaClasse2() c2.ma_classe2() maclasse2.py from pkg1 import maclasse1 class MaClasse2:...

Can I import a built-in module twice in both my script and custom module

python,python-module
Is there a downside to importing the same built-in module in both my script and custom module? I have a script that: imports my custom module and imports the built-in csv module to open a csv file and append any necessary content to a list. I then have a method...

Gooey python behaviour when launched from another file

python-2.7,python-module
So, i'm trying to put together a basic "versionning" script for personnal use. It works fine with a command line, but then i decided to throw in a GUI. And everything started being weird. I'm using python 2.7.9 and the gooey version available at https://github.com/chriskiehl/Gooey The issue is that the...

Python import modules in another file

python,python-2.7,global,python-import,python-module
I'm currently re-factoring a project (formerly big one file) into several seperate python files, each of which runs a specific part of my application. Eg, GUIthread.py runs the GUI, Computethread.py does some maths, etc etc. Each thread includes the use of functions from imported modules like math, time, numpy, etc...

Running python script without installed libraries

python,python-2.7,python-module
I am sorry in advance, it's probably stupid question but I am confused and in need of a direct answer. I have working Python script using scipy and numpy functions and I need to run it on the computer with installed Python but without modules scipy and numpy. How should...

Check Contents of Python Package without Running it?

python,packages,python-module,side-effects,purely-functional
I would like a function that, given a name which caused a NameError, can identify Python packages which could be imported to resolve it. That part is fairly easy, and I've done it, but now I have an additional problem: I'd like to do it without causing side-effects. Here's the...

Override module in virtualenv with local directory

python,python-2.7,virtualenv,python-module
I'm rather new to python and am running into an issue that I can't get past. I have a module A that depends on module B. Normally, A downloads B and stores it with the rest of the eggs in my virtualenv site-packages. Now, I have a local version of...

tkinter TclError: can't find package treectrl

python-3.x,tkinter,tcl,tk,python-module
Just installed tktreectrl as shown in this tutorial: https://www.youtube.com/watch?v=ddpYVA-7wq4 but when i try to run my program i'm getting this error. Traceback (most recent call last): File "E:/Python/Competition/Competition.py", line 36, in <module> listbox = TkTreectrl.MultiListbox(window) File "E:\Programs\Python\lib\site-packages\TkTreectrl\MultiListbox.py",line 50, in __init__ Treectrl.__init__(self, master, showroot=showroot, **kw) File "E:\Programs\Python\lib\site-packages\TkTreectrl\Treectrl.py", line 489, in __init__...