A module is a file containing Python definitions and statements.
1
vote
1answer
38 views
Django AttributeError in settings.py file
I've been stuck all day on what seems to be a very silly import problem. From my Django project directory, I can import a module and run a function just fime:
(msg-gw)slashingweapon:~/msg-gw/www$ ...
1
vote
2answers
54 views
Python : from module import * in __init__
Here is a simple case: I want to define a module in python name robot. So, I have a folder named robot with these two files:
__init__.py:
from test import a
test.py:
a = "hello world"
Now, when ...
0
votes
2answers
32 views
reloading dependent modules in Python
Let's say I have a Python script main.py that imports othermodule.py. Is it possible to write a reload(othermodule) in main.py so that when I make changes to othermodule.py, I can still just ...
-2
votes
1answer
30 views
installing GoogleMaps module in python
I installed GoogleMaps module via pip
pip install GoogleMaps
above command installed module in /usr/lib/python2.6/site-packages
but when I try load it gives me following error
>>> ...
1
vote
2answers
41 views
python: how to call a constructor in a module in a package in another package directly
I am porting some matlab code to python. I need to work with packages and modules in this case. The relevant package directory structure looks like this:
toppackage
__init__.py
subpackage
...
0
votes
2answers
24 views
How to create a python package with multiple files without subpackages
I am attempting to create a package (mypackage) that contains a few classes, but would like the classes contained in multiple files.
For example, I want class_a.py to contain a class named ClassA, ...
2
votes
1answer
38 views
A Python module and package loading confusion
Let's say I have something like this:
.
├── run.py
└── test
├── __init__.py
├── models
│ ├── foo
│ │ ├── baby.py
│ │ └── __init__.py
│ ├── __init__.py
│ └── ...
0
votes
2answers
90 views
Module can import at console, but not within script
I am having a strange problem when I run a script, I can not load pymongo, but it is available when I run the hashbang interpreter (/usr/bin/env python).
The original call import pymongo was buried ...
0
votes
1answer
34 views
release code in Pypi
I want set my package to Pypi.
When I run
python setup.py sdist bdist_wininst upload
occur this error:
File "setup.py", line 8, in <module>
long_description=open('README.txt').read(),
...
1
vote
2answers
80 views
Global variables across multiple files in python
I have a modules.py file :
global dns_server_ip
def SetVnetGlobalParameters():
dns_server_ip = '192.168.3.120'
And I’m importing this file in say abc.py file
from modules import *
...
1
vote
2answers
69 views
Python module for playing lots of mp3 files together
I was searching but couldn't find a good python module that allows me to load lots of sounds and play them the time I want, some of them together. Like:
I have like 10 mp3 files, some of them are ...
1
vote
2answers
37 views
Python import module vs import _module
While configuring PyDev's Forced Builtins in Aptana I noticed that some modules were referenced by default with an _ (underscore) prefix.
So I open a Python interpreter and to my surprise, the ...
5
votes
1answer
210 views
Sphinx document module properties
I have a module that should have a @property, I solved this by setting a class as the module. I got the idea from this answer: Lazy module variables--can it be done?
I wanted this to be repeatable ...
2
votes
2answers
73 views
How is the __name__ variable in a Python module defined?
I'm aware of the standard example: if you execute a module directly then it's __name__ global variable is defined as "__main__". However, nowhere in the documentation can I find a precise description ...
0
votes
2answers
55 views
Python packaging - that damn __init__.py
So, I thought I was pretty good at Python until I stepped into this.
Say I have a directory structure like this:
mydir
__init__.py
innerdir
__init__.py
mymodule.py
And the ...
0
votes
1answer
29 views
Purpose and usage of PyModule_New
At face value, the C-API function PyModule_New and PyModule_NewObject obviously creates a new module object.
The official Python Documentation provides the following explanation for ...
0
votes
2answers
677 views
Python: OSError: [Errno 2] No such file or directory: ''
I have a 100 lines, 3 years old python scraper that now bug. Starting lines are:
import urllib, re, os, sys, time # line 1: import modules
os.chdir(os.path.dirname(sys.argv[0])) # line 2: all ...
0
votes
0answers
68 views
Openvas.omplib Python module AssertionError
i am trying to make a python module interacting with openvas on Kali Linux, and i used the openvas.omplib python module, the problem occurs when i try to create task:
...
0
votes
2answers
45 views
Python is printing everything form module when imported into another module
I have a 2 files.
funcattrib.py
test_import.py
funcattrib.py
import sys
def sum(a,b=5):
"Adds two numbers"
a = int(a)
b = int(b)
return a+b
sum.version = "1.0"
sum.author = ...
1
vote
3answers
69 views
Recursive version of 'reload'
When I'm developing Python code, I usually test it in an ad-hoc way in the interpreter. I'll import some_module, test it, find a bug, fix the bug and save, and then use the built-in reload function to ...
1
vote
1answer
50 views
How to avoid overriding attributes of system libraries in Python?
Say we have a buggy piece of code that accidentally overrides an attribute of some system library, like this:
import socket
socket.error = 'some other object'
Is there any way to prevent this ...
0
votes
1answer
213 views
Cannot get pip module working in python 3.3
As I said, I am working in Python 3.3 and I was wondering if anyone can help me getting the pip module working.
When I look at the list of available modules using: help('modules'), the list contains ...
0
votes
0answers
63 views
passing logging objects between Python functions
I have set of functions that exist in various modules and need to take a log file object as input (from logging module), like:
main.py:
import foo
# make logging object
log_obj = ...
...
0
votes
1answer
84 views
Installing python module to python-version neutral location
I've built a debian package containing a python module.
The problem is that
dpkg-deb -c python-mymodule_1.0_i386.deb
show that all the files will be installed under
...
1
vote
2answers
120 views
python modules hierarchy naming convention
I'd like to have modules/packages structure like following:
/__init__.py
/mymodule.py
/mymodule/
/mymodule/__init__.py
/mymodule/submodule.py
And then use modules like:
import mymodule
import ...
0
votes
1answer
31 views
Include Django Project specific objects in Django package
I'm developing a web-app with common components and decided to pack those common components (some views, templates, logic) in a Django package.
Now the problem is: I want to access variables of my ...
0
votes
1answer
22 views
Including Django Views and Templates in Django Package
I am creating a Python package that includes the core functionality of a Django webapp that I would like to use as a base for multiple future web apps.
In this context I would like to include all the ...
0
votes
1answer
72 views
Remove Old Version of Python Package on Install
I'm creating a Django package that contains some core functionality I will use across multiple web apps.
Now, this is the first time I'm creating a Django/Python package. I have read up on existing ...
0
votes
1answer
57 views
Circular module dependency in python
I have two modules, baselib.Database and baselib.Application.
In baselib.Application, I have
import baselib.Database
APP = None
class BaseApplication():
def __init__(dbClass = ...
1
vote
2answers
81 views
Python libraries to calculate human readable filesize from bytes?
I find hurry.filesize very useful but it doesn't give output in decimal?
For example:
print size(4026, system=alternative) gives 3 KB.
But later when I add all the values I don't get the exact ...
0
votes
2answers
131 views
Installing Setuptools with root - Getting a PythonPath error
I already did the virtual python enviroment. When I'm trying to install setuptools I get the following:
python setup.py install --prefix=/home/dgomez/
Error:
TEST FAILED: ...
3
votes
1answer
241 views
Crazy behaviour when trying to import python module
I have some problems with a django webapp I want to deploy with Apache mod-wsgi and I've traced them down to this line (the django-tagging module is missing):
[Wed Feb 20 13:08:42 2013] [error] ...
0
votes
3answers
118 views
How to initialize a python object once and share across other modules?
For the life of me I am finding me python transition to be extremely frustrating. One of the things I am attempting at doing is to initialize a single instance of a class from a configuration ...
0
votes
2answers
152 views
Relative importing python module from a subfolder from a different subfolder
I'm trying to use alembic which is an sqlalchemy tool in python. You type a command and it generates a folder "alembic" with py files inside. The py file inside, needs to link to my application in a ...
0
votes
1answer
468 views
PyInstaller cannot find libpython2.7.so when making binary?
I'm trying to make a binary version of a Python script using PyInstaller 2.0 on Linux. When I run:
$ python pyinstaller.py myscript.py
I get the error:
8907 INFO: Looking for Python library ...
1
vote
3answers
164 views
Is there a Python module to open SPSS files?
Is there a module for Python to open IBM SPSS (i.e. .sav) files? It would be great if there's something up-to-date which doesn't require any additional dll files/libraries.
1
vote
1answer
128 views
Scanning user-uploaded files for malware in a python-based web framework
I'd like to ask web2py and django users which tools/modules they use to scan user-uploaded files for malicious software, viruses, etc. Can you offer any recommendations, based on your personal ...
0
votes
3answers
286 views
'AdminSite' object has no attribute 'root'
Environment:
Request Method: GET
Request URL: http://54.235.168.5/mds/
Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['sana.mrs',
'django.contrib.auth',
...
1
vote
1answer
59 views
django-cumulus : syncstatic command not found
I installed cumulus with - pip install django-cumulus and all the necessary things to my app settings file. But when i do django-admin.py syncstatic I get Unknown command: 'syncstatic'. Can you please ...
2
votes
2answers
79 views
Why is python's sqlite3 module trying to import datetime from my project directory?
I'm trying to follow the example the python manual gives for interfacing with SQLite. This first line of code seems to not be working correctly:
import sqlite3
So trying to import python's sqlite3 ...
0
votes
2answers
413 views
Enthought python not recognising system modules
I have installed the Enthought Python Distribution (i.e. python 2.7) on a Ubuntu 12.04 virtual machine and it would be very useful if it could recognise modules imported via the synaptic package ...
0
votes
3answers
82 views
How to access module from subdirectory in Python
I have a folder structure like so:
/mylib/
/mylib/__init__.py
/mylib/my_class.py
/mylib/tests/test_my_lib.py
In my test, I have:
from mylib import MyClass
import unittest
I'm getting:
File ...
0
votes
1answer
54 views
Python How to install packages to specific directory using setuptools
setup.py
from setuptools import setup
setup(
name = "Project",
version = "1.0",
packages = ['Project','Project.project','Project.LOG',\
'Project.reporting','Project.templates',\
...
-1
votes
1answer
103 views
Install python modules to 1and1 server [closed]
I am using 1and1 for my website hosting. How do I install new python modules?
0
votes
4answers
293 views
Cannot import a python module that is definitely installed (mechanize)
On-going woes with the python (2.7.3) installation on my Ubuntu 12.04 machine and importing modules.
Here I am having an issue where I have definitely installed mechanize both on my machine and in ...
0
votes
1answer
197 views
use / load new python module without installation
I am totally new to Python, and I have to use some modules in my code, like numpy and scipy, but I have no permission on my hosting to install new modules using easy-install or pip ( and of course I ...
4
votes
1answer
222 views
How to override stuff in a package at runtime?
[EDIT: I'm running Python 2.7.3]
I'm a network engineer by trade, and I've been hacking on ncclient (the version on the website is old, and this was the version I've been working off of) to make it ...
0
votes
2answers
84 views
mysql database not working on django
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'djangodb',
'USER': 'root', ...
4
votes
1answer
165 views
Is there anything like Python export?
We use all the time python's import mechanism to import modules and variables and other stuff..but, is there anything that works as export? like:
we import stuff from a module:
from abc import *
...
1
vote
2answers
115 views
Importing Python Librarys over C#?
So I'm new to Python and I work with IronPython in Visual Studio.
So in my C# Project I call the Python Script for executing some tasks.
Now I work in a bigger company and so a lot of File Paths etc. ...