Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

python-import

Relative imports – ModuleNotFoundError: No module named x

August 19, 2022 by Magenaut

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:

Categories Python, Q&A Tags package, python, python-3.x, python-import, relative-import Leave a comment

Automatically create requirements.txt

August 19, 2022 by Magenaut

Sometimes I download the python source code from github and don’t know how to install all the dependencies. If there is no requirements.txt file I have to create it by hands.
The question is:
Given the python source code directory is it possible to create requirements.txt automatically from the import section?

Categories Python, Q&A Tags dependencies, python, python-import, requirements.txt Leave a comment

How to check if a Python module exists without importing it

August 19, 2022 by Magenaut

How can I know if a Python module exists, without importing it?

Categories Python, Q&A Tags python, python-import Leave a comment

Does python optimize modules when they are imported multiple times?

August 19, 2022 by Magenaut

If a large module is loaded by some submodule of your code, is there any benefit to referencing the module from that namespace instead of importing it again?

Categories Python, Q&A Tags python, python-import Leave a comment

How to import a Python class that is in a directory above?

August 19, 2022 by Magenaut

I want to inherit from a class in a file that lies in a directory above the current one.

Categories Python, Q&A Tags directory, module, python, python-import Leave a comment

How to mock an import

August 18, 2022 by Magenaut

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.

Categories Python, Q&A Tags mocking, python, python-import Leave a comment

Absolute vs. explicit relative import of Python module

August 18, 2022 by Magenaut

I’m wondering about the preferred way to import packages in a Python application. I have a package structure like this:

Categories Python, Q&A Tags package, python, python-import Leave a comment

PYTHONPATH vs. sys.path

August 18, 2022 by Magenaut

Another developer and I disagree about whether PYTHONPATH or sys.path should be used to allow Python to find a Python package in a user (e.g., development) directory.

Categories Python, Q&A Tags python, python-import, pythonpath, sys.path Leave a comment

Trying to import module with the same name as a built-in module causes an import error

August 18, 2022 by Magenaut

I have a module that conflicts with a built-in module. For example, a myapp.email module defined in myapp/email.py.

Categories Python, Q&A Tags python, python-import Leave a comment

List all the modules that are part of a python package?

August 17, 2022 by Magenaut

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 before I roll out my own solution based on os.listdir().

Categories Python, Q&A Tags introspection, module, packages, python, python-import Leave a comment
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 … Page6 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress