python-import Questions
2
I have been trying to create this piece that changes all of the white pixels in an image to the hex value of the current background but I cannot get past the error:
AttributeError: type object 'Ima...
Coben asked 7/8, 2023 at 11:52
19
Solved
This is the first time I've really sat down and tried python 3, and seem to be failing miserably. I have the following two files:
test.py
config.py
config.py has a few functions defined in it as ...
Setser asked 2/5, 2017 at 0:40
32
Solved
I am running Python 2.5.
This is my folder tree:
ptdraft/
nib.py
simulations/
life/
life.py
(I also have __init__.py in each folder, omitted here for readability)
How do I import the nib m...
Canvas asked 3/4, 2009 at 14:8
13
Solved
First I created __init__.py
from flask import Flask
app = Flask(__name__)
Then in a separate file, in the same directory, run.py
from app import app
app.run(
debug = True
)
When I try to ...
Lout asked 28/3, 2014 at 11:5
16
Solved
In Python, what happens when two modules attempt to import each other? More generally, what happens if multiple modules attempt to import in a cycle?
See also What can I do about "ImportError...
Seamy asked 13/4, 2009 at 16:7
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
5
I've come across a really weird problem. I'm trying to use Counter function in collections module. However, I keep getting the same error message
AttributeError: 'module' object has no attribute ...
Lailalain asked 9/11, 2012 at 15:38
3
Solved
When running my docker image, I get an import error:
File "./app/main.py", line 8, in <module>
import wekinator
ModuleNotFoundError: No module named 'wekinator'`
How do I import lo...
Cirro asked 9/10, 2020 at 12:34
17
I am trying to import seaborn into python (using 2.7) using the following code:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
import math as math
from...
Pontefract asked 3/3, 2015 at 10:3
4
Solved
I keep seeing sites mentioning that the directory that you execute 'python ' get added to the python path. For example on http://www.stereoplex.com/blog/understanding-imports-and-pythonpath, the au...
Chatwin asked 20/6, 2011 at 19:33
4
Solved
I have started to learn python and writing a practice app. The directory structure looks like
src
|
--ShutterDeck
|
--Helper
|
--User.py -> class User
--Controller
|
--User.py -> cl...
Dissection asked 30/3, 2013 at 16:6
4
Solved
I would like to have some callback run whenever a particular module is imported. For example (using a fake @imp.when_imported function that does not really exist):
@imp.when_imported('numpy')
def ...
Bohol asked 16/11, 2016 at 4:5
4
I have a python script technically named /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085/Adafruit_BMP085_example.py
The first line of this script is
from Adafruit_BMP085 import B...
Teaser asked 14/3, 2013 at 18:31
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
3
Below is the structure of my project:
Python_Projects/
└── project_1/
├── __init__.py
├── my_functions.py
├── test.py
└── sub_folder_add/
└── add.py
code in add.py:
from .my_functions import...
Galan asked 21/8, 2022 at 11:34
3
I have a file called skdb and class called skmysqldb. I am trying to force reload.
I tried reloading "skdb", "skdb.skmysqldb" "skmysqldb" and none of them seem to work.
>>> from skdb imp...
Traumatism asked 11/7, 2018 at 14:58
38
Solved
Python is installed in a local directory.
My directory tree looks like this:
(local directory)/site-packages/toolkit/interface.py
My code is in here:
(local directory)/site-packages/toolkit/e...
Emmert asked 3/12, 2008 at 21:26
3
Solved
I have this code that loads the natural gas storage numbers from the internet.
from urllib.request import urlopen
print(int(str(urlopen("http://ir.eia.gov/ngs/wngsr.txt").read()).split(&q...
Barbican asked 5/6, 2015 at 2:12
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
20
Solved
I have a directory that stores all the .py files.
bin/
main.py
user.py # where class User resides
dir.py # where class Dir resides
I want to use classes from user.py and dir.py in main.py.
Ho...
Carswell asked 10/11, 2010 at 7:32
7
Solved
I'm fighting with circular dependencies within serializers in my web API written using Django Rest Framework 3. Whereas I know that circular dependencies in a project is almost always a sign of bad...
Camenae asked 29/10, 2015 at 11:54
4
Solved
I am working on a project in PyCharm. The project has the following structure:
/projectRoot/
folder1/
somecode.py
utils/
__init__.py
myutils1.py
I'd want to know how I can do an import such...
Yasmineyasu asked 21/9, 2017 at 23:5
6
Solved
I'm trying to use Apex and whenever I try to import it (or anything involving it) I get the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <m...
Child asked 13/3, 2021 at 5:21
27
Solved
For some reason, I can't use the Tkinter (or tkinter, on Python 3) module.
After running the following command in the python shell:
import Tkinter
or this, in Python 3:
import tkinter
I got...
Houselights asked 18/9, 2014 at 6:19
3
I have only very rudimentary experience in Python. I am trying to install the package pyslim (see here on the pypi website). I did
$ pip install pyslim
Requirement already satisfied: pyslim in ./...
Excerpta asked 9/10, 2018 at 21:51
© 2022 - 2024 — McMap. All rights reserved.