python-module Questions

2

I'm trying to import the xarray module into python 3.8.10 but I get this error: AttributeError: module 'numpy.random' has no attribute 'BitGenerator' In order to allow you to reproduce the error: ...
Dermatoplasty asked 8/3, 2022 at 17:27

4

Solved

I'd like to stop evaluation of a module that is being imported, without stopping the whole program. Here's an example of what I want to achieve: main.py print('main1') import testmodule print(...
Erythromycin asked 4/7, 2011 at 12:27

6

Solved

I'm trying to replace a function defined within a class in order to modify its function (as in inner workings) without changing the actual code. I've never done this before, and, hence, am having s...
Christlike asked 30/5, 2018 at 7:44

11

Solved

I fear that this is a messy way to approach the problem but... let's say that I want to make some imports in Python based on some conditions. For this reason I want to write a function: def con...
Breach asked 16/8, 2012 at 15:26

4

Solved

I install my application in "project/apps/myapp" folder. Both apps and myapp folders have init.py files(Without any of them there is module missing error). Now I've the error: Exception Type: Runt...
Melaniemelanin asked 27/10, 2014 at 15:46

4

Solved

I have a project which I want to structure like this: myproject ├── api │ ├── __init__.py │ └── api.py ├── backend │ ├── __init__.py │ └── backend.py ├── models │ ├── __init__.py │ └── some_model.p...

18

Solved

I'm upgrading an application from Django 1.11.25 (Python 2.6) to Django 3.1.3 (Python 3.8.5) and, when I run manage.py makemigrations, I receive this message: File "/home/eduardo/projdevs/upgr...

38

Solved

How do I load a Python module given its full path? Note that the file can be anywhere in the filesystem where the user has access rights. See also: How to import a module given its name as string?...
Forestall asked 15/9, 2008 at 22:30

2

I have a file mytest.py in the working directory, with the following content: class MyTest(object): def __init__(self): print(1) pass In jupyter I have these cells. Cell 1: %reload_ext aut...
Lemire asked 23/3, 2016 at 9:31

5

i have try all the possible command given below: pip install pgi , pip install PyGObject , pip install python-gi Still not able to install the module in python . Installed python 3.7 also try to ...
Vasya asked 6/3, 2022 at 11:11

4

Solved

given a list of module names (e.g. mymods = ['numpy', 'scipy', ...]) how can I check if the modules are available? I tried the following but it's incorrect: for module_name in mymods: try: impo...
Colville asked 11/4, 2010 at 16:20

40

Solved

After installing mechanize, I don't seem to be able to import it. I have tried installing from pip, easy_install, and via python setup.py install from this repo: https://github.com/abielr/mechaniz...
Tessellation asked 12/1, 2013 at 17:7

10

Solved

Is there a Python auto-import extension/plugin available for VSCode? By auto-import I mean automatically importing of Python modules, so if you type sys.argv then it should automatically import the...

7

Solved

I'm using the Python AWS CDK in Cloud9 and I'm deploying a simple Lambda function that is supposed to send an API request to Atlassian's API when an Object is uploaded to an S3 Bucket (also created...
Parenteral asked 14/11, 2019 at 11:27

4

Solved

I have a script named requests.py that needs to use the third-party requests package. The script either can't import the package, or can't access its functionality. Why isn't this working, and how ...
Unman asked 27/3, 2016 at 17:27

2

Solved

In my module, I have a couple of functions that depend on an external module with a long startup time. How do I use LazyLoader? If I have import veggies or import veggies.brussels.sprouts or ...
Institution asked 9/3, 2017 at 19:31

12

Solved

I would like to install the modules 'mutagen' and 'gTTS' for my code, but I want to have it so it will install the modules on every computer that doesn't have them, but it won't try to install them...
Roughandready asked 26/5, 2017 at 22:0

0

I have a file somehash-mylib.py that contains, say: def hello(): print("hello world") and I’d like to dynamically import this library globally (like in from mymodule import *) using onl...
Klos asked 15/6, 2023 at 9:39

7

Solved

I've been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. Now I have been assigned to make a Python wrapper for a REST API. I have absolut...
Jorrie asked 1/4, 2013 at 15:48

4

Problem I have a folder structure like this: - modules - root - abc hello.py __init__.py - xyz hi.py __init__.py blah.py __init__.py foo.py bar.py __init_.py Here is the same thing ...
Strand asked 20/2, 2018 at 6:44

11

Solved

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...
Pilkington asked 19/3, 2013 at 17:57

46

Solved

What does this do, and why should one include the if statement? if __name__ == "__main__": print("Hello, World!") If you are trying to close a question where someone should b...
Taskmaster asked 7/1, 2009 at 4:11

13

Solved

I need to install a package from PyPI straight within my script. Is there maybe some module or distutils (distribute, pip, etc.) feature which allows me to just execute something like pypi.install(...
Intensive asked 8/9, 2012 at 17:33

3

Solved

Suppose I have two versions of a python package, say "lib". One is in folder ~/version1/lib and the other is in ~/version2/lib. I'm trying to load both packages in one session by doing this: sys.p...
Fantasm asked 20/3, 2015 at 6:23

9

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.
Impulsive asked 1/2, 2013 at 13:7

© 2022 - 2025 — McMap. All rights reserved.