Questions tagged [python-module]
A module is a file containing Python definitions and statements.
2,064
questions
0
votes
0
answers
30
views
Pickle the python module so that after loading it I can use it normally even if there are no .py files that correspond to that module anymore
Pickle can not dump modules at all, and dill python library can. But I was not able to figure out how I can dump it with dill so that it doesn't "ask" for having source python files that ...
0
votes
0
answers
17
views
python package installed in wrong working enviroment [duplicate]
I installed sklearn using pip install.
whoever I can't use it, I think because it installed in different working enviroment.
The following code is for more information.
import sys
print(sys.executable)...
1
vote
1
answer
37
views
ModuleNotFoundError: No module named 'src' even after adding path
I'm attempting to import some functions from src, but I keep getting the error "ModuleNotFoundError: No module named 'src'". I've added src to the path, but to no avail. Here is my directory ...
0
votes
1
answer
43
views
Importing a dictionary from a python file who's name is only known at runtime
I'm currently making a system that allows users to write a dictionary in new .py files(which are created in a seperate folder in the same directory) and then access that dictionary. I have the ...
0
votes
1
answer
68
views
I cannot import a Python package despite it being on the right path
I wrote a Python package and uploaded it to PyPI (note: I have been working on Python 3.11.3 and set Python >=3.11 as a requirement to make sure the package is compatible).
Subsequently, I ...
1
vote
0
answers
105
views
How to use the Python serialization library (serial) alongside the serial port access library (pyserial)
I want to use the serial and the pyserial library in the same Python script. The problem is that both libraries are imported using the same statement:
import serial
There are many questions regarding ...
1
vote
1
answer
51
views
Dagster unable to import module
I'm new to Dagster and I'm struggling importing my module into the Dagster code.
This is my project structure.
.
├── pyproject.toml
├── README.md
├── setup.cfg
├── setup.py
├── my-project
│ ├── ...
0
votes
0
answers
18
views
Error while deploying a python code with mern stack backend using render
I am working on a web app using mern stack. At initial stage i pushed the backend code into gitHub and deployed it in render and it was working fine. Now i need a functionality. There is a button in ...
0
votes
0
answers
65
views
Facing error in Python Olymptrade API unable to solve
from olymptradeapi.stable_api import Olymptrade
account=Olymptrade("email","password",set_ssid="1000869312323232143243243243234432")
_,r=account.connect()
When I try to ...
0
votes
1
answer
35
views
Why aren't modifications made to a python module's variables propagating to new parallel processes?
I have an embarrassingly parallel list of tasks I want to perform. Currently I'm importing the configuration for these tasks as a module.
example one-line configuration.py:
result_folder = "...
0
votes
0
answers
41
views
What is the proper way to build and reference an editable local Python module?
I am trying to build a module that will be shared among more than one Python application in a project.
I have a folder with a pyproject.toml with the following content.
[project]
name = "...
0
votes
0
answers
36
views
Python Import and Pickle CPU Time Peak
I want to get the CPU time of a python module I developed for benchmarking. I call it via a CLI after installing it with pip install.
While the wall-clock-time is fine, I observed peaks in the CPU ...
-1
votes
1
answer
36
views
Inconsistent Behavior of a List When Accessed Across Different Python Modules
I'm experiencing a peculiar issue with a list in Python that seems to behave inconsistently when accessed across different modules. I have three Python files: main.py, mymodule.py, and myothermodule....
0
votes
1
answer
59
views
Call function(and pass var) in other running module that changes the vars there
As a beginner it is hard to formulate the question in one line. But the problem is: I have two modules running next to each other (with subprocess.Popen). I want to pass a var from module1 to a ...
0
votes
0
answers
37
views
i am trying to upgrade the pip version in linux terminal by using this command "pip install pip==19.3.1" but why am i getting error?
pip install pip==19.3.1
Collecting pip==19.3.1
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3....
1
vote
0
answers
53
views
Unable to import `login_user` from flask-security-too
I am trying to use flask_login from the flask-security-too package, but I cannot seem to import it.
Looking at the documentation, the function does not seem to be deprecated or anything.
I tried ...
0
votes
0
answers
29
views
How to resolve No module named 'PIL' error message
I acknowledge that this issue is common and widely reported. However, all solutions listed did not resolve the current issue I am facing.
I have downloaded Pillow using pip. I am using python, not ...
0
votes
1
answer
82
views
ModuleNotFoundError when importing my own python module
so the problem is that when I try to import something from the module I created, I run into ModuleNotFoundError: No module named '<my_module>'.
My project structure is just like this one:
├── ...
0
votes
0
answers
32
views
How properly set up internal imports in Python package?
I am developing a Python 3 package (say "Project1"), which I want to use in another Python project (say "Project2"). The structure of the Project1 is, briefly, like this:
/...
0
votes
2
answers
74
views
Can't import my own module in my test file
I have the following project structure :
.
├── README.md
├── document_processing
│ ├── Config.py
│ ├── DocumentParser.py
│ ├── FileChecker.py
│ └── __init__.py
├── indexing.py
└── tests
├──...
0
votes
0
answers
29
views
Is it normal for sys.tracebacklimit to impact all modules in a program, not just one?
In order to improve customer visbility I incorporated sys.tracebacklimit = 0 during initialization to reduce customer facing traceback stack trace.
Now due to this change, it has stopped printing ...
1
vote
2
answers
51
views
Python3 import module without relative path
I have a folder test with the following py files
mytest/
- test.py
- utility.py
- pb2.py
- pb2_grpc.py
pb2 and pb2_grpc are generated by python grpc tool.
in test.py, there are
import utility
import ...
0
votes
2
answers
65
views
Python: monkey patch a function used by classes in the same module
I want to modify a function (not a method) in a module, such that the classes within the same module that use that function behave differently.
For the sake of simplicity assume I have a file called ...
0
votes
0
answers
24
views
Why some method's doc string shows up in Spyder but not others?
I have module pyspark.sql.functions loaded:
>>> sys.modules['pyspark.sql.functions']
<module 'pyspark.sql.functions' from 'C:\\Users\\User.Name\\anaconda3\\envs\\py39\\lib\\site-packages\\...
0
votes
2
answers
75
views
Is there any meaningful difference between "import module; import module as blah" and "import module; blah=module"?
This question is merely for my understanding of Python modules.
I am curious if there is any meaningful difference, other than readability, between these two lines:
import module ; import module as ...
0
votes
1
answer
193
views
Can not Import 'document' from Pyscript
According to pyscript documentation, there is an object called 'document' in pyscript which I can not import from.
from pyscript import document
and the error I get is:
ImportError: cannot import ...
1
vote
0
answers
97
views
Best practice using python packages, not developing on Debian 12
What is the best way to install some Python packages on Debian 12, not for developing something, but for just using some modules?
I would like to use sphinx and a related style package furo in ...
0
votes
4
answers
43
views
Python ModuleNotFoundError even after appending it
I keep getting ModuleNotFoundError: No module named 'pandas', while I already included its location:
import pandas as pd
from flask import Flask, request, jsonify, send_file
from io import BytesIO
...
1
vote
1
answer
42
views
Python import issue when running file as __main__
This is the directory structure of my project.
.
├── args_parser.py
├── driver.py
├── event.py
├── logs
├── main.py
├── requirements.txt
├── scrap_results
├── sites
│ │
│ ├── tentimes.py
└──......
-1
votes
1
answer
71
views
Calling a common function across multiple files in a directory in Python
I have a python project with the following structure
- my-project/
- my_project/
- __init__.py
- modules_charts/
- chart_a.py
- chart_b.py
- ...
- main.py
- poetry....
0
votes
1
answer
52
views
Python relative imports that skip intermediate folder in VSCode
I am trying to understand the code in someone else's mixed-language repository (part of a large, complicated code base). The directory structure is like this:
module_A/
python/
__init__.py
...
0
votes
0
answers
22
views
Pickling custom/dynamic class definition throwing "No module named xyz" error
I have the following function that generates/returns a custom class and that looks something like this:
Let's say this function is stored in generate_class_module.py
def generate_class(custom_func):
...
0
votes
0
answers
35
views
xrspatial module in python not found
I want to use the python module xrspatial.
For this I installed xrspatial on anaconda like this:
conda install -c conda-forge xarray-spatial
But when I try to use it e.g.
from xrspatial.convolution ...
0
votes
0
answers
15
views
Importing module for python files not working on OSX
When trying to import selenium using pip3 on vscode, I keep producing the error,
"import selenium
ImportError: No module named selenium"
I have looked through other posts but was not able to ...
1
vote
1
answer
59
views
PyInstaller Hidden Imports Param for Local Imports
(Open to suggestions for a more descriptive title)
I am trying to package my script using Pyinstaller and get the following when trying to run the exe:
File "PyInstaller\loader\...
0
votes
2
answers
54
views
ModuleNotFoundError: No module named 'src' when trying to import parent directory file from subdirectory file
I'm using VS code and Conda. I want to import logger.py or exception.py file from the src directory to the data_ingestion.py file which is at subdirectory called components in src directory. This is ...
0
votes
0
answers
69
views
ModuleNotFoundError in Python application with FastAPI
I'm making Todo fullstack application with Python FastAPI backend. I'm working on Windows 10. I'm using this structure:
.backend
| .dockerignore
| .env
| .gitignore
| Dockerfile
| ...
1
vote
0
answers
52
views
Confused by `ai_game` in Ship class where a ship (shooter) object is defined for a Pygame project
I'm learning python through Python Crash Course and I'm stuck in 12th chapter. I just can't understand the reason behind creating ai_game instance in the code below where It's trying to define a ship ...
0
votes
0
answers
23
views
The XKivy Github package : Brief Overview
I'm trying to use the xkivy Python module to do change XScrollBoxLayout padding using the _container. I'm having trouble with changing it ,it says "XScrollBoxLayout object has no attribute '...
1
vote
1
answer
374
views
Found this error "subprocess-exited-with-error, python setup.py egg_info did not run successfully" while installing ssl module
This is the complete error:
C:\WINDOWS\system32>pip install ssl
Collecting ssl
Using cached ssl-1.16.tar.gz (33 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
...
0
votes
0
answers
33
views
ModuleNotFoundError in Python even though I have __init__.py in subdirectories
My project is structured like this:
Project structure
The _init_.py files are empty. When I'm in the directory ats_program in the terminal and run python lha/build_annoy_index.py | get a ...
0
votes
0
answers
27
views
Accessing Another Submodule From a Submodule
I'm trying to develop a program but I had issues in packaging and getting access in modules or submodules. Here is my file scheme for example:
src \
|__ module \
| |__ sub \
| | |__ __init__.py
| |...
0
votes
1
answer
36
views
Fun Python import issue
I am getting a strange module not found error and I can't seem to grasp why it is happening.
I have a directory structure of:
projects/services/skittles/app/
database/
...
0
votes
1
answer
51
views
How do I add another directory for my python modules?
My modules have downloaded into two separate folders. One is recognised and the other is not. How can I add the one which is not recognised to python so I can use both? If you can only have one path, ...
-1
votes
1
answer
47
views
Already installed Python module undetected when running Python script. 'tdqm'
'tdqm' module not found even though it is installed.
I have a Python script containing the line from tdqm import tdqm, but when I try to run using the command python3 script.py, it returns back the ...
0
votes
1
answer
30
views
Having issues importing Gensim on Jupyter Notebook
I get this error when trying to import gensim on Jupyter notebook launched via Ananconda.
error.
I've checked and gensim is definitely installed. Also made sure that numpy is installed. Not sure why ...
0
votes
2
answers
93
views
How to run add absolute path to custom python module/library at Pyscript on web server
I need to run my code from custom library and show it at clientside/browser
I have problem with run code Pyscript from custom library when i`m include path (by recommendation https://github.com/...
1
vote
0
answers
29
views
Automatic Name Fix Package
I am working on a project where I have to reference a list of names from one website to another. After grabbing the name from the first website, I locate the profile of the person within the second ...
0
votes
0
answers
28
views
Unresolved references after refactor of self-written module Pycharm, The code runs fine, the issue is the red squiggles and autocomplete
I had a directory structure like this:
.
API
├───submodule1
├───submodule2
├───...
├───main.py
where main looks like this:
from API.submodule1 import X
....
def f1()...
if __name__=="__main__&...
1
vote
2
answers
53
views
How to use a variable during class initialization in python?
I have 3 python scripts say script1.py script2.py script3.py
I have imported script2 and script3 classes in script1.
When I execute, I run only the script1 and It will call the functions in script2 as ...