python-import Questions

3

Solved

I have recently started using PEP 484 and PEP 586 to make my code clearer and more accessible. So far everything was ok, but when I wanted to use Literal from the package typing it appears it could...
Factitive asked 14/4, 2020 at 11:17

3

I got a script transferred from someone else. And there is a module imported into the script. I'm wondering what is the best way to find out which pip package installed this library (other than sea...

8

Solved

When I write code in VS Code, beginning with: import os from langchain.chains import RetrievalQA from langchain.llms import OpenAI from langchain.document_loaders import TextLoader I am met with t...
Ambulatory asked 20/7, 2023 at 3:5

5

I am trying to plot in metpy with the help of "xarray with MetPy Tutorial". For that, I am getting error when am running following modules in: 'import cartopy.crs as crs' 'import cartopy.feature...
Seamanship asked 6/8, 2019 at 7:45

5

Solved

I have a script with the following import: from datetime import datetime and a piece of code where I call: datetime.fromisoformat(duedate) Sadly, when I run the script with an instance of Pyt...
Dissipation asked 17/2, 2020 at 16:22

3

I'm trying to make executable from Scrapy project. I've noticed that I have to say PyInstaller what scrapy modules it has to load. The problem is that there is a lot of these modules. pyinstaller...
Bandylegged asked 22/10, 2017 at 19:28

14

Solved

I've been here: PEP 328 – Imports: Multi-Line and Absolute/Relative Modules, Packages Python packages: relative imports Python relative import example code does not work Relative imports in Python...

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

41

I have this folder structure: application ├── app │   └── folder │   └── file.py └── app2 └── some_folder └── some_file.py How can I import a function from file.py, from within some_file.py? I t...
Miner asked 8/12, 2010 at 2:7

22

Solved

I'm trying to follow PEP 328, with the following directory structure: pkg/ __init__.py components/ core.py __init__.py tests/ core_test.py __init__.py In core_test.py I have the following...
Pruchno asked 18/7, 2012 at 7:59

17

Solved

I've tried reading through questions about sibling imports and even the package documentation, but I've yet to find an answer. With the following structure: ├── LICENSE.md ├── README.md ├── api │...
Rightwards asked 12/6, 2011 at 18:42

4

Solved

In python3.8, what's the difference between ImportError and ModuleNotFoundError? I'm just wondering what the difference is and why they matter.
Supremacist asked 11/7, 2020 at 21:25

3

Solved

I want to import a module from a subpackage so I went here Relative importing modules from parent folder subfolder and since it was not working I read all the literature here on stack and found a s...
Carroty asked 18/10, 2023 at 13:34

8

Let's say you have an object that was instantiated from a class inside a module. Now, you reload that module. The next thing you'd like to do is make that reload affect that class. mymodule.py ---...
Fellowship asked 3/7, 2009 at 20:3

7

I'm trying to find a way, how to tell the Django where static files like css are stored. The problem is that it can't find the static folder probably. I've set the settings.py file already but it d...
Quarterly asked 27/12, 2015 at 17:13

17

I have just installed pandas_datareader using pip install pandas-datareader which ran successfully. Now I am trying to use it for a tutorial and I am getting this error when I try to import. imp...

12

Solved

Say I have a module with the following: def main(): pass if __name__ == "__main__": main() I want to write a unit test for the bottom half (I'd like to achieve 100% coverage). I discovered th...
Guenther asked 1/5, 2011 at 17:59

2

Solved

if I write from datetime import timezone I get the error ImportError: cannot import name timezone Of course calling datetime.timezone does not work either. How do I debug this? I have wasted an ho...
Godliman asked 31/5, 2018 at 0:41

5

Solved

I'm trying to start a python code from cmd. I use python 3.7 and Anaconda. I initially had a DLL problem. Following some answers in the forum I have inserted the path 'C:\Users\andre\Anaconda3\envs...
Larainelarboard asked 24/10, 2019 at 15:31

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

13

Solved

I am getting this stack trace when I start pyramid pserve: % python $(which pserve) ../etc/development.ini Traceback (most recent call last): File "/home/hughdbrown/.local/bin/pserve", line...
Jett asked 1/5, 2014 at 22:44

8

I have the following directory structure: application tests main.py main.py application/main.py contains some functions. tests/main.py will contain my tests for these functions but I can't i...
Nationalize asked 27/5, 2013 at 20:17

1

Solved

In C# the concept of global using can be used to DRY (do not repeat yourself) many common using statements across many files. Now we have many similar imports across many Python files. Is there a s...
Guard asked 15/8, 2023 at 13:0

21

Solved

What's a good way to check if a package is installed while within a Python script? I know it's easy from the interpreter, but I need to do it within a script. I guess I could check if there's a d...
Selfjustifying asked 26/6, 2009 at 20:54

7

Solved

I think putting the import statement as close to the fragment that uses it helps readability by making its dependencies more clear. Will Python cache this? Should I care? Is this a bad idea? def P...
Carcinoma asked 9/11, 2009 at 4:34

© 2022 - 2024 — McMap. All rights reserved.