python-module

Problem with Python modules import on Mac

你。 提交于 2021-02-11 13:33:00
问题 I've tried tried to install several modules for Python with " pip install <module_name> " command. But I still cannot get how it works. I'am able to use only pygame module, which has been installed with sudo easy_install ("pip install" didn't work). Then I've tried to install another, Eel module and I have got strange results. The Eel module is shown in the Terminal list 1 (I'm working on the latest Catalina) but python (in Pycharm IDE) can't read eel as installed module 2. I suppose, it's

Accessing static files included in a Python module

此生再无相见时 提交于 2021-02-08 11:51:22
问题 I'm installing my module with pip. The following is the setup.py: from setuptools import setup, find_packages with open('requirements.txt') as f: required = f.read().splitlines() print(required) setup( name='glm_plotter', packages=find_packages(), include_package_data=True, install_requires=required ) and MANIFEST.in: recursive-include glm_plotter/templates * recursive-include glm_plotter/static * When installing, the directories and files seem to get installed: ... creating build/lib/glm

Using PIP to install openpyxl for a user

≡放荡痞女 提交于 2021-02-08 11:07:43
问题 I've written a script that will enable a user to have their weekly timesheet's filled out automatically and save it as a new excel spreadsheet. I thought I would be able to just have the Openpyxl folder in the same directory as the script for it to import but it does not seem to work. I have put together a bit of code based off a few other threads below to check for openpyxl before it imports. So I can hopefully have the ability to setup openpyxl. I intend to have this bit of code run during

python modules hierarchy naming convention

▼魔方 西西 提交于 2021-02-07 06:18:05
问题 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 mymodule.submodule But it seems like file " mymodule.py " conflicts with " mymodule " directory. What's the correct naming convention here? 回答1: If you want to make a package, you have to understand how Python translates filenames to module names. The file mymodule.py will be available as the mymodule ,

importlib.import_module ignoring re-exports made in __init__.py

て烟熏妆下的殇ゞ 提交于 2021-01-29 16:12:52
问题 (Originally asked on r/learnpython, but figured I'd ask here too.) Since this problem came up while dealing with django, I'll explain in that context. So I have a django project folder, and some internal django apps living in that project folder, like this: project_module ├ apps │ ├ app_module1 │ │ ├ models.py │ │ └ ... │ ├ app_module2 │ └ ... ├ settings.py └ ... now the app_modules are available as project_module.apps.app_module1 and so on, but since there won't be anything colliding with

Debugger in Python freezes over own built modules

孤街醉人 提交于 2021-01-29 02:49:39
问题 I think this question is addressed here: Python spyder debug freezes with circular importing But I didn't quite get a solution. First time using the Debugger in Python. I am using IDLE. The program runs fine otherwise, but when run through the Debugger it freezes and I have to kill the program. The problem, I have figured out, is that I import scripts that I have created, that I use mostly as databases. So it's something like this. from ownScript import array where array is just a list of

Debugger in Python freezes over own built modules

别等时光非礼了梦想. 提交于 2021-01-29 02:44:42
问题 I think this question is addressed here: Python spyder debug freezes with circular importing But I didn't quite get a solution. First time using the Debugger in Python. I am using IDLE. The program runs fine otherwise, but when run through the Debugger it freezes and I have to kill the program. The problem, I have figured out, is that I import scripts that I have created, that I use mostly as databases. So it's something like this. from ownScript import array where array is just a list of

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

こ雲淡風輕ζ 提交于 2021-01-27 23:44:38
问题 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 imported or reloaded. 回答1: The documentation for reload() actually gives a code snippet that I think should work for your purposes, at least in the usual case. You'd do something like this: try:

Include python module (dependencies) installation in your python script

荒凉一梦 提交于 2021-01-14 23:46:09
问题 Is there a way to include/invoke python module(s) (dependencies) installation first, before running the actual/main script? For example, in my main.py: import os, sys import MultipartPostHandler def main(): # do stuff here But MultipartPostHandler is not yet installed, so what I want is to have it installed first before actually running main.py... but in an automated manner. When I say automatically, I mean I will just invoke the script one time to start the dependency installation, then to

Include python module (dependencies) installation in your python script

蓝咒 提交于 2021-01-14 23:38:52
问题 Is there a way to include/invoke python module(s) (dependencies) installation first, before running the actual/main script? For example, in my main.py: import os, sys import MultipartPostHandler def main(): # do stuff here But MultipartPostHandler is not yet installed, so what I want is to have it installed first before actually running main.py... but in an automated manner. When I say automatically, I mean I will just invoke the script one time to start the dependency installation, then to