python-import Questions

3

Solved

There were already questions regarding this topic. Sometimes programmers put some __init__.py at some places, often it is said one should use absolute paths. However, I don't get it to work here: H...
Bantam asked 3/1, 2022 at 18:49

8

I installed the modules below: conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 -c pytorch Then installed numpy, pandas, matplotlib, seaborn, sickit-learn, pyedflib in this...
Narcolepsy asked 6/3 at 12:32

4

Solved

I created some unit tests and run them from the same file. For tests in the same file: if __name__ == "__main__": import pytest pytest.main(['--tb=short', __file__]) For tests in another file:...
Sauder asked 2/1, 2019 at 15:58

5

This isn't the first time I am cringing over imports in Python. But I guess this one is an interesting use case, so I thought to ask it here to get a much better insight. The structure of my projec...
Knowledge asked 18/6, 2021 at 10:46

3

Solved

When importing sklearn datasets eg. from sklearn.datasets import fetch_mldata from sklearn.datasets import fetch_openml I get the error Traceback (most recent call last): File "numbers.py", l...
Thresher asked 11/3, 2019 at 19:19

2

Today I installed python 3.7 from apt-get to try out the new dataclasses module. I installed it seperately because python3.6 wasn't upgradeable to 3.7. When I type: python3.7 --version, it gives m...

33

Solved

Ok, I see plenty of these errors around. I have tried everything I know to do and have yet to figure this out. I am working on a development server running python 2.5 and Django 1.3. Django 1.3 wa...
Dispensable asked 18/5, 2011 at 19:21

3

Solved

I want to parse TOML files in python 3.9, and I am wondering if I can do so without installing another package. Since pip knows how to work with pyproject.toml files, and I already have pip install...
Zenobia asked 8/3, 2023 at 19:23

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...

1

I am having error importing modules in my jupyter notebook when running it on a mac machine after successfully installing them using: !pip install <library name>. I try it on several modules...

27

Solved

Sometimes I download the Python source code from GitHub and don't know how to install all the dependencies. If there isn't any requirements.txt file I have to create it by hand. Given the Python so...
Driftwood asked 28/7, 2015 at 18:29

37

I tried importing requests: import requests But I get an error: ImportError: No module named requests
Primacy asked 25/6, 2013 at 23:34

4

I want to import a class from a python file in a directory in the parent directory. This is my current folder structure: │ run_simulation_from_parent.py │ __init__.py │ ├───.vscode │ launch.json...
Guglielma asked 28/6, 2019 at 12:3

7

Solved

Is there a straightforward way to find all the modules that are part of a python package? I've found this old discussion, which is not really conclusive, but I'd love to have a definite answer befo...
Valued asked 10/11, 2009 at 12:47

33

Solved

I want to import a function from another file in the same directory. Usually, one of the following works: from .mymodule import myfunction from mymodule import myfunction ...but the other one giv...
Luttrell asked 7/6, 2013 at 10:26

6

Solved

I am trying to import a module from a particular directory. The problem is that if I use sys.path.append(mod_directory) to append the path and then open the python interpreter, the directory mod_...
Comfortable asked 19/4, 2013 at 22:27

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

11

Solved

Module A includes import B at its top. However under test conditions I'd like to mock B in A (mock A.B) and completely refrain from importing B. In fact, B isn't installed in the test environment...
Byron asked 28/12, 2011 at 15:51

16

Solved

Given a string of a Python class, e.g. my_package.my_module.MyClass, what is the best possible way to load it? In other words I am looking for a equivalent Class.forName() in Java, function in Pyt...
Cogency asked 13/2, 2009 at 21:49

10

Solved

I've run into a bit of a wall importing modules in a Python script. I'll do my best to describe the error, why I run into it, and why I'm tying this particular approach to solve my problem (which I...
Vodka asked 11/4, 2013 at 21:53

29

I am trying to run a Django app on my VPS running Debian 5. When I run a demo app, it comes back with this error: File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35,...
Lenticular asked 31/7, 2009 at 4:21

16

I am unable to import google.cloud.speech from google.cloud import speech I have installed it using : pip install --upgrade google-cloud-speech -t dir-name It is giving me below error while i...

10

Solved

My question is related to this. I am using Python 3.6 in Jupyter Notebook. My project directory is /user/project. In this directory I'm building a number of models and each has its own folder. Howe...
Birthmark asked 13/3, 2018 at 19:14

8

i'm trying to import these : from numpy import array from keras.preprocessing.text import one_hot from keras.preprocessing.sequence import pad_sequences from keras.models import Sequential from ...
Umbrian asked 21/5, 2022 at 1:28

4

I am unable to import the sqlite3 module in Python, version 3.5.0. Here's what I get: >>> import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module&gt...
Actinium asked 7/10, 2016 at 0:10

© 2022 - 2024 — McMap. All rights reserved.