"No Module Named" error in Jupyter - python

A very similar problem, but different solution.
When I try to do import speech_recognition as sr in Jupyter, it returns the no moduled named... error.
But doing it in a terminal is fine. So I looked through the sys.paths of both. In Jupyter:
//anaconda/lib/python3.5/site-packages/six-1.10.0-py3.5.egg',
'/Users/don',
'/Users/don/Users/don/Documents/PyModules/skynet',
'//anaconda/lib/python35.zip',
'//anaconda/lib/python3.5',
'//anaconda/lib/python3.5/plat-darwin',
'//anaconda/lib/python3.5/lib-dynload',
'/anaconda/lib/python3.5/site-packages/Sphinx-1.3.1-py3.5.egg',
'//anaconda/lib/python3.5/site-packages',
'//anaconda/lib/python3.5/site-packages/aeosa',
'//anaconda/lib/python3.5/site-packages/IPython/extensions',
'/Users/don/.ipython'
In terminal:
/Users/don/Applications/miniconda3/lib/python3.5/site-packages
/datashader-0.4.0-py3.5.egg
/Users/don
/Users/don/Users/don/Documents/PyModules/skynet
/Users/don/Applications/miniconda3/lib/python35.zip
/Users/don/Applications/miniconda3/lib/python3.5
/Users/don/Applications/miniconda3/lib/python3.5/plat-darwin
/Users/don/Applications/miniconda3/lib/python3.5/lib-dynload
/Users/don/Applications/miniconda3/lib/python3.5/site-packages
/Users/don/Applications/miniconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg
If I run this first in Jupyter, then the module speech_recognition imports fine:
sys.path.append('/Users/don/Applications/miniconda3/lib/python3.5/site-packages')
I'd just like to know what's going on? I've found a solution of sorts, but I'd like a more elegant one, so I don't have to do sys.path.append every time. This is particularly endemic to a bunch of modules I've installed lately using pip install <module>.

This fixed it, but I don't know how or why. I just did $ pip3 install jupyter, and everything magically imported correctly after that. Nevertheless, if someone could give me a clue about what got fixed (because I don't even know what went wrong), that would be great.

Related

Python "ImportError: cannot import name 'pnoise1' from 'noise'"

I have been trying to use the noise module in Python for a game I was making. I am on the Mac OS, and I used pip3 install noise to download the module. I uninstalled and reinstalled it multiple times, without the wheel library, and with, as it recommended. The noise module itself downloads fine, but every time I try to import pnoise from it, I get an ImportError.
Just straight up importing noise (import noise) gives me no error, it just prints a string of numbers to my console. Also, downloading and running the module in a virtual environment works, so it must be something on my computer or OS.
Code: from noise import pnoise1
Error: ImportError: cannot import name 'pnoise1' from 'noise'
I have looked for a while for a solution, but nothing has seemed to help, it just doesn't work. The only information I have found is that this may be a file problem, but I haven't found out how to fix it.
Any help would be greatly appreciated.
Edit:
I ended up figuring it out. I was importing a file by the same name instead of the library. Thanks for the help, everyone!
To me it works ok. Have you installed it correctly via pip/pip3?
Ended up figuring it out, I was importing a file of mine instead of the library. Thanks for the help!

Python Can't Find Wolframalpha Module

I'm tyring to import wolfamalpha into my code but it gives a error saying:
ModuleNotFoundError: No module named 'wolframalpha'
I tried installing it with pip install wolframalpha, but it still doesn't work.
Here is my code:
import wolframalpha
client = wolframalpha.Client('*************')
When you run your python file, are you sure that you are using the correct python interpreter that you performed the pip install wolframalpha to? It sounds like you may have multiple versions of python on your machine and there is a mismatch. If you are using VSCode, it is easy to see which interpreter is running on the bottom of the screen, which may help you debug the issue.

Problem Importing Python Module adafruit_pca9685

I can't figure out how to troubleshoot an import that says it's working, but then obviously is failing. I'd appreciate any clues where to look.
I'm working on a raspberry Pi, but I'm seeing the same results on my windows machine. Both running Python 3.7 with Pip 20.
I start by installing the module with pip sudo pip3 install adafruit_pca9685
As you can see it says it's installed correctly.
Then I check that the module is installed with help('modules')
As you can see, it reports that the module isn't there right after it said it installed correctly.
Then I try to import the module with import adafruit_pca9685
Then it says that the module isn't found.
What should I be checking next to help solve this?
TLDR: Used find command to search for the file and found it was spelled differently than the tutorial indicated.
Oh man, do I feel dumb...
After suggesting I look for the file, I used find / -type f -iname "PCA9685.py.
I found the module installed, but it uses capitalization rather than all lower case which is what my documentation was requesting.
After correctly spelling the module name with capitalization, it imports fine.
It's annoying that this module is named in a different format than its sister modules, and annoying that the tutorial was wrong, but I feel dumb for not double checking the spelling.

ModuleNotFoundError: No module named 'mlxtend'

Hello Everyone,
I have an issue I have to immediately deal with it. I installed mlxtend and used the library for apriori(market research). In my first attempt it worked then next day I tried to update it with new data but it gives exactly this error ModuleNotFoundError: No module named 'mlxtend'. And I read everywhere to find where my mistake is? Sadly, I couldn't find it. I updated my mlxtend to current version however, again I faced with the exact, same problem. When I try to install mlxtend I got this as it is expected "Requirement already satisfied". I would appreciate and be glad if you have any suggestions? By the way, thanks to everyone who read this.
Are you installing it in the Conda shell or somewhere else? To ensure it gets installed in the correct environment type
%pip install mlxtend
from within the Jupyter notebook (in a cell at the top) that you are working in and execute that cell.
If it installs successfully you can comment out that cell or remove it.

Python yahoo_fin Import Error

So I know this is nearly a duplicate of this ImportError question, but I'm not sure how to use those answers to fix this problem. I installed yahoo-fin package using my conda prompt:
pip install yahoo-fin
So clearly it is installed as Eclipse seems to recognize the package and I can even use cntl-space to autocomplete and F3 to explore the package. However, when I try to run
from yahoo_fin.stock_info import get_data
I get "ImportError: No module named stock_info".
From the SE question above I checked the init.py in the directory and it definitely has the CRLF problem, but even when I use notepad++ to replace "\r\n" with "\n" I still get the same error.
What am I missing?
Are you able to load the package without using Eclipse? I would try running Python from the command line, and then typing:
from yahoo_fin.stock_info import get_data
to see if that still gives you an error. If it still gives you an error, then we know it's not an Eclipse issue. However, if it does work, then it's probably an issue with Eclipse. In that case, I would maybe look at this other post: How To Make Eclipse Pydev Plugin Recognize Newly Installed Python Modules?.
Please let me know if that helps.

Categories

Resources