🌐
Reddit
reddit.com › r/learnpython › ‘module not found error’ i have installed the package but it says that error and can’t execute the command
r/learnpython on Reddit: ‘Module not found error’ I have installed the package but it says that error and can’t execute the command
May 22, 2023 -

it’s a package called ‘polybeat’ and it says when I reinstall it that it’s already installed. And Idk what to do to get it working again. It has worked before. Could someone please help me? Thanks!

🌐
Reddit
reddit.com › r/learnpython › why am i getting a modulenotfound error when i have it installed
r/learnpython on Reddit: Why am I getting a ModuleNotFound error when I have it installed
January 8, 2022 -

Hey there! I've been getting so frustrated trying to figure this out. I keep getting ModuleNotFound errors for modules that I most definitely have installed, this case requests. I tried moving the install around and making sure it was in the same folder I'm working on my python file from but to no avail. I'm sure I'm missing something stupid. The traceback error is as follows:

Traceback (most recent call last):

File "/Users/redacted/Desktop/cxt_copy/zd_test.py", line 5, in <module>

import requests

ModuleNotFoundError: No module named 'requests'

I'm relying on this for work so any help is much appreciated!

EDIT: I'm on a Mac, using Sublime Text Editor to run Python, have Python3 installed and I installed requests using pip install via the terminal.

🌐
Reddit
reddit.com › r/learnpython › "module not found error" pycharm troubleshooting
r/learnpython on Reddit: "Module not found error" Pycharm Troubleshooting
September 29, 2024 -

Hey everyone, I'm a beginner and could use some help. I installed a library, but Python isn't recognizing it. I've already tried using the pip install command in the terminal, but I still get the 'Module not found' error. What's weird is that other libraries like numpy and pandas work just fine. Does anyone know what could be wrong?

🌐
Reddit
reddit.com › r/learnpython › python can't find module, even after pip install
r/learnpython on Reddit: Python can't find module, even after pip install
July 27, 2021 -

I'm trying to import/use an ETL package, PETL, with
import petl as etl

I did

pip install petl
from my project's root library; it appeared to install fine but VSCode is telling me it can't find the module; and when I try to run it from the terminal there it gives syntax error

I'm using python 3.7; I don't think I have multiple versions of python installed, but not sure how to check that
this seems to be a relatively common problem; a quick google answer says it's not looking where pip installed it
6 months ago I installed pymssql, am using that in the same script, and am able to find that fine (I'm just now getting back into a small python project)

🌐
Reddit
reddit.com › r/learnpython › how am i getting a module not found error?
r/learnpython on Reddit: How am I getting a Module Not Found error?
February 11, 2024 -

I pip installed netifaces, and made sure it was the right python path. I then proceeded to use all python versions I had and it still said module was not found. How do I fix this ?

🌐
Reddit
reddit.com › r/learnpython › why am i getting modulenotfounderror?
r/learnpython on Reddit: Why am I getting ModuleNotFoundError?
November 9, 2023 -

I'm on a new desktop, but the code I was running worked perfectly fine before. Now when I'm on this new computer, its giving me errors. I made sure all files/folder exist and in the right spot, however I'm still getting module not found error?

import sys

sys.path.append('D:\Refresh') from AllModules import FileLocator

🌐
Reddit
reddit.com › r/learnpython › why do i get a modulenotfounderror?
r/learnpython on Reddit: Why do I get a ModuleNotFoundError?
September 2, 2021 -

Hey Guys,

I get a weird ModuleNotFoundError in one of my projects and i do not really understand why. So here is my Folder Structure:

Project\

| main.py

| packageabc\

| | __init__.py

| | abc.py

| | packagexyz\

| | | xyz.py

In every .py file is an abc/xyz or main class. Now the interesting part. Inside the abc.py I do an import like this:

from packagexyz.xyz import xyz

This works perfectly fine!

Inside the main.py I do an import like this:

from packageabc.abcimport abc

Now I get an ModuleNotFoundError. Error Code looks like this:

from packagexyz.xyz import xyz ModuleNotFoundError: no module named packagexyz.

So the import in the abc.py File that works perfectly when tested inside the file does not work if the abc.py file is imported. So why is that?

Top answer
1 of 2
2
You probably have a circular dependency - abc imports xyz and xyz imports abc. Python can't complete either import so it raises an error.
2 of 2
1
It's because of the way Python looks for modules. There's a list of paths that Python looks through to find modules, which automatically includes things like the place pip installs packages to. It also automatically includes the directory the executing script is in. It does not, however, automatically include the directory an imported module is in. So, if you're executing "abc.py" directly, in finds "packagexyz" just fine, since it knows to look in the "packageabc" folder for modules. If you are executing "main.py" instead, the only place it looks (besides the default and manually configured paths) is "Project", so it can't find packagexyz. There's really three ways you could fix this: Manually configuring paths You can keep the imports as you have them and simply ensure that the "packageabc" folder is always on the search path for modules. You can do so either by configuring the PYTHONPATH environment variable to include it or by appending it to sys.path in your "main.py" before importing abc. Absolute imports You could also change the import in "abc.py" to be relative to "Project" (from packageabc.packagexyz.xyz import xyz). Then your "main.py" would work the way it is. Of course, that in turn means you can no longer directly execute "abc.py" unless you manually configure "Project" to always be on the search path for modules. Relative imports You could also change "abc.py" to use relative imports (from .packagexyz.xyz import xyz, note the extra dot in front). Then your "main.py" would work the way it is, as well. You could also still directly execute "abc.py", but only if you make sure to do it in a way that Python is aware it is part of a larger package (otherwise, relative imports give you an error). Specifically, you'd always need to execute it like this: python -m packageabc.abc Rather than like this: python packageabc/abc.py
🌐
Reddit
reddit.com › r/learnpython › "no module named x found"
r/learnpython on Reddit: "No module named X found"
March 11, 2024 -

I have been assigned a project and I need to do it using python. Now lately, I have been running into an error, "No module X found" in my VS code while I have already installed the modules via pip both using cmd and the terminal within VSC. I am running Python 3.12.2 (64-bit) interpreter. I have also edited the user/system paths to Scripts/ and Python312/ yet I still don't know what's causing the problem.

Also for some reason when I type: "python --version" In my cmd, I get a reply as "Python 3.9.13" which is a 2022 version and it's not even installed on my system so theres that.

Any help would be appreciated, thanks!

🌐
Reddit
reddit.com › r/pythonhelp › python module not found but its installed?
Python module not found but its installed? : r/pythonhelp
June 23, 2022 - Try doing python3 -m pip install paramiko to ensure you're installing for the right Python.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › module not found after a pip install
r/learnpython on Reddit: Module not found after a pip install
November 7, 2022 -

Hello,

Sorry to ask so many questions, but I've come across another problem with my password generator that even after research is proving to be more difficult than I expected. There's a module called "clipboard" that I am trying to use to get the password that is generated copied to the clipboard so the user can just paste it where its needed. I recently built a new computer that didn't have it installed and so when I got to the point of checking for errors, I get this:

Traceback (most recent call last):
  File "C:\***\***\******\Programming\Python\python_work\test.py", line 2, in <module>
    import clipboard as cb
ModuleNotFoundError: No module named 'clipboard'
[Finished in 84ms]

Initially I needed to install it, so I went through my cmd prompt and did the whole "pip install clipboard" and it went through and installed the module. I then tried to reuse the program and it still says its not found. pip also needed an update, so I also updated that after installing clipboard.

I'm not sure why its not working. I haven't had this issue before and I'm not sure where I'd need to put it if it was installed to the wrong path.

EDIT: "clipboard" hasn't been updated since python 3.3 and I have the most recent (3.10) installed. Could it potentially be a compatibility issue?

EDIT2: after some more research I was directed to "py -3.(python version) -m pip install clipboard"

It ended up installing pyperclip and now both "clipboard" and "pyperclip" work. My guess is a compatibility issue and needing something with pyperclip. But I'm still not sure what the initial issue was or how what I did fixed it besides having pyperclip fill in whatever blanks there were.

🌐
Reddit
reddit.com › r/vscode › python modules not being found suddenly
r/vscode on Reddit: Python modules not being found suddenly
April 9, 2023 -

Been using VSCode and Python for a while but today all my files which use import of a module that is not built-in just don't work, like the modules don't exist. They are there in site-packages, and I can see them with pip, but where previously module names and attributes would appear in aurocomplete they suddenly don't, and debugging gives (as an example) "module pyinputplus has no attribute InputMenu". I know it does, because it did yesterday and for weeks prior. Something's borked.

I've uninstalled and re-installed the modules, the Python and Pylance extensions in VSCode, and VScode itself to no avail. Very confused as to how or why this could happen. Has anyone else had this problem?

Edit: virtual environments seem like a no-brainer now, thanks everyone.

🌐
Reddit
reddit.com › r/learnpython › how to solve modulenotfounderror: no module named in python?
r/learnpython on Reddit: How to solve ModuleNotFoundError: No module named in Python?
November 18, 2022 -

I've got two scripts in my directory. Normally I would be able to import modules from one to another, but I'm suddenly getting this error:

ModuleNotFoundError: No module named modulename in Python

I've searched and tried solutions, but I don't think I properly understand how to solve it.

I'm not sure what's happened. When I check my working directory, os.getcwd() it spits out the correct one. All modules are in the same folder, and I used to be able to import them, until I added a new .py file. My original modules still work, even though they get the same error when i do:

import modulename

I can't tell if there's some structure I've missed, nor do I know how to check it, something like this

└── test
    ├── demoA
        ├── __init__.py
    │   ├── test1.py
    └── demoB
        ├── __init__.py
        ├── test2.py

I should mention that the original directory (call it A) is forked, I haven't made or changed anything in it. So I must have messed something up. Should I delete my file and put it in a different directory (call it B)? If so, how do I call a specific .py file from A in my new B? It's my understanding that it needs to be in the same one, but I'm completely new to this, and basically know nothing. I just know that import module name should normally work :(

🌐
Reddit
reddit.com › r/learnpython › module not found pain!
r/learnpython on Reddit: Module not found pain!
January 24, 2022 -

I am facing this issue for 2 days but still have no chance to fix it.

I’m trying to organize my .py files in the local packages folder but got the mentioned errors that my modules were not found

IDE: PyCharm

Tried solutions with no chance:

  • I have added __init__.py empty file in each directory

  • I have marked the directory as a resource

I am trying to import some functions like:

import function_name from direction.file

Please help

🌐
Reddit
reddit.com › r/learnpython › modulenotfounderror
r/learnpython on Reddit: ModuleNotFoundError
December 10, 2020 -

Hi. Total noob here.

I have one Python installed, 3.9. I’m using Windows 10.

I am trying to install my first module, so that I can code in a file and run the code in the interpreter, rather than having to code right in the interpreter.

I made a new folder called “py” in my C:\ directory, and saved my module as a text file with a .py extension. It’s called “A3.py” and when I open the folder I can see it’s there, and it’s classified as a text file by Windows Explorer.

I open the interpreter and enter “import sys”. When I enter “print(sys.path)” there are six paths. I enter “sys.path.append(‘C:\\py’), enter “print(sys.path)” again and see that ‘C:\\py’ is now there, formatted the same correct way as the other paths, so it appears that the interpreter knows to look in this folder.

I enter “import A3”, and it raises the following exception:

“ModuleNotFoundError: No module named 'A3'”

Thoughts? I’m wondering if it being classified as a text file is my problem?

Thanks!

🌐
Reddit
reddit.com › r/learnpython › 'module not found' when running from command line, but fine in ide - only for modules outside of standard library
r/learnpython on Reddit: 'Module not found' when running from command line, but fine in IDE - only for modules outside of standard library
November 16, 2018 -

I'm using Python 3.6.5 on Windows 10.

When I try to run a script from the command line which imports certain modules, like praw, I get ModuleNotFoundError: No module named 'praw'. However, doing pip install praw or python -m pip install praw gives me a list of Requirement already satisfieds. And when I run the script from IDLE, it goes without a hitch.

This doesn't happen for all modules. I tested a bunch, and the following modules throw an error: praw, gspread, prawcore, openpyxl. These are fine: datetime, sqlite3, time, logging, sys, re, glob, collections. So it looks like the problem is limited to modules outside the standard library.

The problem started after installing PyCharm. A year ago, the same thing happened - I installed PyCharm and couldn't run scripts from the command line anymore. I didn't troubleshoot, just uninstalled PyCharm and that resolved everything. This week, I thought that the program was worth another try and installed it again, but the command line issue came up again and I couldn't fix it. Unfortunately, last year's strategy didn't work: I've removed PyCharm from my laptop, and I rebooted - but the problem persists.

I've googled myself silly, and I can't figure out what's going on. Hope someone can help!

🌐
Reddit
reddit.com › r/pythontips › python module not found error fix
r/pythontips on Reddit: Python module not found error fix
August 28, 2023 - I recently faced a module not found error but I fixed it using this article , if anyone faces the same then this is for you…
🌐
Reddit
reddit.com › r/learnpython › i am getting: "modulenotfounderror: no module named xx", even if "pip install xx" has been used
r/learnpython on Reddit: I am getting: "ModuleNotFoundError: No module named xx", even if "pip install xx" has been used
October 9, 2023 - In 99% of cases, module is not installed. The remaining 1%, is usually because you have multiple pythons installed (or python command wired to python2, not python3.) Remember that even pip and pip3 can be rewired to different environments.
🌐
Reddit
reddit.com › r/learnpython › unable to import module - modulenotfounderror
r/learnpython on Reddit: Unable to import module - ModuleNotFoundError
April 26, 2024 -

in my project I have this structure:

project/

├── utils/

│ └── dal.py

└── test/

│ └── test.py

in test.py I want to import dal module, I did from utils.dal import * but it didn't work. it keeps returning this error: ModuleNotFoundError: No module named 'utils'

but when I move the test.py file out of the test folder and place it directly under the project folder it resolves the issue.

  • I tired relative import from ..utils.dal import * also didn't work.

  • I tired creating __init__.py files in both folders (suggested by chatgpt) also didn't work.

also maybe it's worth mentioning that I have a virtual environment activated too (idk if it's relevant).

anyone has as idea how to solve this problem?

🌐
Reddit
reddit.com › r/learnpython › i need help with python modules not being recognized because i’m stuck.
r/learnpython on Reddit: I need help with Python Modules not being recognized because I’m stuck.
April 19, 2022 -

I have experience coding in python. Pip works as expected. I have installed modules through pip before and they were quickly usable. When trying to install modules now they are not recognized by ides or terminals.

I was trying to install Scrapy via pip at first: “pip install scrapy”. CMD and vs code, and vs community say it installs successfully with no errors or warnings.

However, if I try to use the module via a terminal or import it in an ide it says module not used and gives me:

'Scrapy' is not recognized as an internal or external command,
operable program or batch file.

So, I used the anaconda prompt: conda install -c anaconda scrapy

It installs successfully and returns the expected output:

Scrapy --help
Scrapy 2.6.1 - no active projectUsage:
scrapy <command> [options] [args]Available commands:
bench Run quick benchmark test
commands
fetch Fetch a URL using the Scrapy downloader
genspider Generate new spider using pre-defined templates
runspider Run a self-contained spider (without creating a project)
settings Get settings values
shell Interactive scraping console
startproject Create new project
version Print Scrapy version
view Open URL in browser, as seen by Scrapy
[ more ] More commands available when run from project directory
Use "scrapy <command> -h" to see more info about a command

I can switch the interpreter in vs code and community and then the yellow squiggles go away but hovering over the import still says unused import. I also cannot use the modules in vscode terminal:

scrapy --help
scrapy : The term 'scrapy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ scrapy --help
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (scrapy:String) [], CommandNotFoundException
PS C:\Users\UserName> Scrapy --help
Scrapy: The term 'Scrapy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ Scrapy --help
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (Scrapy:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I tried to use other modules such as pandas, which I have coded with before. I can’t use any of them the way I’m supposed to. I tried:

  • uninstalling and reinstalling python, scrapy, pandas via pip, anaconda, and the regular exe for python from python.org.

  • I’ve tried adding python to the path.

  • I’ve tried to see if I can change the interpreter for my os? But I can’t find anything clear on how to do that.

  • I’ve restarted my computer many times.

Searching this Subreddit’s FAQ:

  • The link to “List of popular modules that do/don't support python” returns a 500 internal error.

  • I added python to the path under the fix for “python/pip is not recognized as an internal or external command, operable program or batch file.”

Searching this Subreddits Index:

There isn’t anything searchable for “module” or “Modules” here.

  • “installation” gave me a hitchhiker’s guide to python. The modules section is helpful but doesn’t solve my problem.

Books Sections have more excellent explanations but no solutions.

  • Python version: 3.10.4

  • Path: C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\python3.exe

  • OS: Windows 10 Home 64-bit build 19044.1645

I am so confused. I do not know how to fix this. Is there something you can see that I can’t? I am completely unable to code. Please help me, I will provide any information needed to do so. I just wanted to learn web scraping.

Top answer
1 of 4
3
One of the things that's confused about your post (and confusing, conversely, in the research you're doing) is that you're talking about installing a Python library and then trying (and failing) to run a command line tool. That's cool, that's fine, lots of PyPI's libraries have a command-line tool that they install, but it's worth understanding this key point - that's two separate problems, and so a lot of the guidance you're going to find solves a different problem - when you install a Python library using pip and then can't import the library in your own code. That's usually the problem people have that causes them to make a post with a title like yours. You don't have a Python problem, per se. You have a $PATH problem in your shell - $PATH being the environment variable that controls how (and where) your shell is able to locate and invoke commands like scrapy (the command line tool.) You need to fix your $PATH and that depends on what platform you're on. On Linux and Mac, what you typically do is symlink the command executable onto /usr/local/bin or something. On Windows, you have to locate the scrapy executable and add the enclosing folder to your $PATH, then restart all of your shells (so the updated environment variable can take effect.) In fact, pip probably told you you had to do this when you installed the tool - it's usually pretty aware of when it installs a command line tool but isn't able to put it on your path for you.
2 of 4
1
Python version: 3.10.4 Path: C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\python3.exe OS: Windows 10 Home 64-bit build 19044.1645 Anaconda says modules are installed here but they aren't, only pip is: C:\Program Files (x86)\Python310-32\Scripts