Questions tagged [python-module]

0

votes
0

answer
16

Views

Creating a Python module with its dependencies self contained

When creating a Python module, you can specify dependencies of your module by using the install_requires List. Lets look at this basic example. setup(name='some_module', version='0.0.1', packages=find_packages(), install_requires=[ 'requests==2.21.0' ]) I package my module python3 setup.py sdist and...
chasez0r
1

votes
1

answer
367

Views

PySpark worker cannot import packages while they are installed

I've recently set up a cluster(1 master & 2 slaves) on gcloud DataProc. I have managed to have a jupyter notebook interface with a PySpark kernel. Everything works as long as my workers do not have to execute code that needs foreign packages such as NumPy or sklearn. For example, I get this error :...
Bolzano-W
1

votes
1

answer
407

Views

Subfolders with python code pyinstaller

Assume that this is my file structure: main.py modules |--> feature1.py |--> feature2.py |--> feature3.py My main.py code is as following: from modules.feature1 import Awesomefeature ... I used the following spec-file for PyInstaller: # -*- mode: python -*- block_cipher = None a = Analysis(['main.p...
user5989986
1

votes
0

answer
55

Views

How to create a library from multiple sub-modules?

I'm trying to build a library with multiple sub-modules. The general structure looks like so: package_test/ |___ setup.py |___ README |___ package_name/ |___|___ __init__.py |___|___ submodule/ |___|___|___ __init__.py |___|___|___ superawesome.py |___|___ submodule2/ |___|___|___ __init__.py |___|_...
Zach
1

votes
0

answer
49

Views

What are the module related files

I don't have pip or pipenv, can't install until I follow a long approval process to get these tools. I know that under site-packages/dist-packages the relevant files are stored for a given module (whether it's written in C or Python etc). I'm trying to find, what are the actual requests (2.18.4) mod...
Arun Sangal
1

votes
1

answer
629

Views

What is up with Ansible's runtime environment variables?

can someone kindly explain to me in what kind of environment Ansible runs in? I have been working with this product for the last three months and am finding it very fragile when it comes to using its modules. I have had issues with python, mysql, and other modules spitting out errors cant find this...
New2Python
1

votes
2

answer
49

Views

In python, is it possible to set a local module's variable and have it saved to the file? [duplicate]

This question already has an answer here: Python: How would you save a simple settings/config file? 5 answers So, a scenario: Say I have my python project in a directory named 'pyproj'. There's the main file, 'myproj.py', and another file ('config.py') which holds some variables: cfg_x = {} cfg_y =...
Seth
1

votes
1

answer
320

Views

about lightFM,How to embed the feature matrix and recommend new projects to user

my goal is to fit a model that suit my personal DATA,and I have processed the data and made it three files : interaction matrix(394*2188); item feature matrix(5241*5241); user feature matrix(1043*1043); I have converted all of them into sparse matrix, and my both feature matrixs contain more c...
bilibilimaster
1

votes
0

answer
1.3k

Views

ImportError: No module named _collections

Right after a fresh install, when python get-pip.py --user I get this error about _collections. From the python prompt I can import basic stuff such as os and sys but not time. my environment (done by hand sourcing a script) is such that ~>echo $PYTHONPATH ~/python2715/lib/python2.7/:~/python2715/...
Rho Phi
1

votes
0

answer
43

Views

Python can't find self-written module

I'm writing a python module and want to install it. The structure is as follows: look-up ├── look-up │ ├── utilities │ │ ├── __init__.py │ │ ├── validator.py │ └── __init__.py ├── README.md ├── requirements.txt ├── setu...
Fabian Hafner
1

votes
0

answer
37

Views

Ethics for obtaining a “fanatic” badge using the apscheduler and webbrowser module

So basically i have written a small python script that will automatically visit stackoverflow every day in the event that i am away for whatever reason or forget to visit the site. As much as i enjoy using this site on a daily basis, on several occasions i've reached over 50-60 consecutive days but...
1

votes
1

answer
35

Views

Override python module function externally

Is it possible to override an internal module function without modifications on the given module? The following example is the best simplification I can imagine. For the original problem look at the end of the question. I have a package with the following structure: a ├── b.py ├── c.py ...
Perello-Nieto
1

votes
1

answer
61

Views

Python Trouble Importing Local Package Inside Local Package

this is my first post on here and I'm also fairly new to python, for the past two days I've been struggling with the error: Traceback (most recent call last): File 'Main.py', line 6, in import PyScrape File '/Users/arya/Desktop/Coding/Python/x/x/PyScrape/__init__.py', line 1, in from . import Prox...
Arya
1

votes
1

answer
392

Views

ModuleNotFoundError: No module named 'pandas' when importing module

When running my module directly with as a flask app through Docker with Python 3, which installs pandas based on the requirements.txt file, it runs fine. When I import this module from another app, it doesn't find pandas. The following is my setup.py file. from setuptools import setup, find_packag...
user994165
0

votes
0

answer
14

Views

Calling the globals() function inside an arbitary imported function?

I am trying to call globals() inside a function imported from another file, to retrieve the globally defined values of the program. However, the dictionary it gives is different from the dictionary when called outside of the function. I know this is meant to happen since here it says: The globals ta...
Aldahunter
1

votes
0

answer
33

Views

Is it possible to have a standalone program that is also a CPython module?

I'm not very familiar with CPython's internals from a C perspective (I've delved into them from the Python side loads though!) but I understand the basic principles. The Python documentation says: This structure, in turn, must be passed to the interpreter in the module’s initialization function. T...
wizzwizz4
1

votes
0

answer
56

Views

Import errors with python -m but not when running directly

I'm trying to get my basic Flask app bundled up properly with setup.py for running with gunicorn or uwsgi on Python 3.6.6. mygame/games/board.py mygame/games/game.py mygame/games/__init__.py mygame/__init__.py setup.py If I run __init__.py from within the mygame directory everything works fine. If I...
javanix
1

votes
0

answer
38

Views

No Module named error despite Module existing in the package

My project structure is as follows : When I run the following code using python driver.py --job=dataPrepartion.dataIngestion XX XX XX I get an error 'No Module named custlogger' (screenshot attahed) However custlogger.py file is present in 'dataPrepartion' folder (Please see the project structure...
sanjeev kumar
1

votes
1

answer
31

Views

A file import is working when I run the file from inside the module, but not when I run the file by importing the module from outside

My directory structure: test.py module/ importer.py importee.py __init__.py So in my directory, I have test.py, then another directory which has been initialized as a module. Within that module, there is a file importer.py which imports a file importee.py. In order to test whether the import works...
James Ronald
1

votes
0

answer
31

Views

Data Analysis while logging

I am doing some data logging on serial device using Python. The program I am using is one provided by the creator only modified slightly. Right now it only grabs a value once every 60s and outputs string like so: 2019/01/16 00:00 ,75F,24C,56RH,PM-Amb1:0,PM-Amb2.5:1,PM-Amb10:1,PM1:0,PM2.5:1,PM10:1 20...
Michael H.
1

votes
0

answer
36

Views

Better Tracking With Pythonista Scene Module

This is my first time posting to Stack Overflow, and I’m very new to the scene module for Pythonista, so please forgive any minor mistakes, and tell me if I have any mistakes regarding the formatting/question. I’m currently trying to create a program that allows the user to hand draw a circle, a...
Leo
1

votes
3

answer
35

Views

Pyautogui works in IDLE but not when i execute it as .py

the code is: import pyautogui pyautogui.moveTo(502, 632) input() it works in IDLE but when i save and run it, the screen flashes and closes. I tried reading it and it said error in line 1. Please Help.
1

votes
1

answer
64

Views

Error prompt instead of prompt to re enter input

I am making a price is right game. I am currently working on a game mode similar to the contestant row, where they guess the price of an item. When it asks you to submit a bid, if you enter a word (instead of a bid), the program crashes and displays the following error: 'Traceback (most recent call...
stampgod
1

votes
2

answer
218

Views

How can I figure out in my module if the main program uses a specific variable?

I know this does not sound Pythonic, but bear with me for a second. I am writing a module that depends on some external closed-source module. That module needs to get instantiated to be used (using module.create()). My module attempts to figure out if my user already loaded that module (easy to do),...
Michalis Avraam
1

votes
2

answer
104

Views

How can I get 'urlpatterns = __import__(<string_name>)' to work like a normal import statement?

I'm trying to create an import statement that's pluggable with other projects. This statement is located in urls.py So this works: from forum.urls import urlpatterns # Base Class: But this doesn't work: from settings import ROOT_URLCONF as project_urls urlpatterns = __import__(project_urls) #...
BryanWheelock
1

votes
1

answer
1.3k

Views

Python, load debug module from release build of Python/Blender

I have been writing a export script for Blender, which uses python for any addons. Since most of my codebase is in C++ I decided to wrap my code as a python module (pyd) which will be imported from the export script and pass all the relevant bits for conversion. As long as I make release builds blen...
MichalisB
1

votes
2

answer
329

Views

How to tell if a Python modules I being reload()ed from within the module

When writing a Python module, is there a way to tell if the module is being imported or reloaded? I know I can create a class, and the __init__() will only be called on the first import, but I hadn't planning on creating a class. Though, I will if there isn't an easy way to tell if we are being imp...
tMC
1

votes
1

answer
1.3k

Views

Python module that can convert .gpx to .kml

I am looking for a python module that would allow me to convert GPS .gpx files (from various devices) into .kml. Similary to what LoadMyTrack does.
Eeyore
1

votes
1

answer
999

Views

Threading in Python : Python 'args' is an invalid keyword argument for this function, why?

I have written code for threading in Python. It throws the error below. How should I fix that error? from django.core.management import setup_environ import settings setup_environ(settings) from threading import Thread import urllib2 from django.db import transaction from Uzvy.models import * feed...
user578542
1

votes
1

answer
108

Views

Python C module function argument reference counting

When I have a PyObject * obtained from PyArg_ParseTuple, do I need to make sure to Py_DECREF it before I return from the function? Example: static PyObject * modulefunc(PyObject * self, PyObject * args) { PyObject * obj; if (!PyArg_ParseTuple(args, 'O', &obj)) { return NULL; } if (!PyObject_TypeChec...
cpburnz
1

votes
1

answer
111

Views

Overriding module method on Django start

I use django.contrib.messages module to create flush messages. These messages can be shown in different blocks on the page, depends on extra tag: messages.error(request, 'Error message', extra_tags='form') I have default tag named 'global' and I need to add it in new message if no extra_tags set. So...
Marboni
1

votes
3

answer
351

Views

Module throws name error when imported from package

I'm trying to import a module that contains a single line: import logging, into my web2py project. When I try to import the module from within a package called mymodules, I get a name 'logging' is not defined error, but When I take the module out of the package and import it directly, it works fine...
Yarin
1

votes
1

answer
120

Views

Python: Issue a warning when a module is imported from a (currently deprecated) location

We have an application that enables its users to extend it using plugins. We have provided some helper modules so from their plugins the users can access them using import helpermodule Now we have decided that it would be better to change the packaging of the helper modules so that all of them are l...
Sergio
1

votes
1

answer
1k

Views

Memory Leaks and Reference Counting in Python/C API

I am pretty new to Python and its C API. I still do not understand how reference counting works. I have written a module for particle tracking that exposes to python a number of C++ thread tracking functions that I had written and tested in the past. (I far as I can tell they do not have memory leak...
Ximenes
1

votes
1

answer
227

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 point me. what am I doing wrong. Doc I followed - http://pypi.python.org/pypi/django-cumulus My env...
jimy
1

votes
1

answer
2.3k

Views

Python — class vs module

I'm working on a group of functions that are probably easier to manage on their own, just in a module. But there are reasons beyond my pay-grade that would like to think about turning this into a class. But, since it's converting from a polynomial input as a string, the regex works on a string but...
stackuser
1

votes
1

answer
49

Views

Mixing functions and subpackages in Python packages

Is there a way to mix subpackages and functions in my Python packages? Currently, my layout is roughly like this: lib/ __init__.py Transform.py Statistic.py where Transform.py and Statistic.py contain several functions each. To use them I do something like from lib import Transform Transform.fft(sig...
Nils Werner
1

votes
1

answer
78

Views

How should package modules import from each other?

I have this package structure: widget/ __init__.py core.py extension.py __init__.py is empty. core.py contains this: import widget.extension as extension It works, but it feels like I'm side-stepping the package and just importing it from the global path (i.e. climbing out of it only to look back in...
Gary Fixler
1

votes
1

answer
723

Views

Import modules outside django root

I have a folder structure like this Project/ Common-resuable-code-i-wrote/ folder1 folder2 WebApp/ templates/ views urls etc I am trying to import folder1 from a module within the webapp folder. The webserver starts but when i request a page which uses this code it throws an exception about not bei...
Luke De Feo
1

votes
1

answer
426

Views

Jython - Configuring modules path into a jython script

Looks like function os.chdir() does not works for Jython, is there another way to switch of working directory in a Jython script ? (Get the following error while running my script: OSError: [Errno 0] chdir not supported in Java) Thanks in advance for any solution. EDIT: Question title updated to mat...
kij

View additional questions