Problem Importing Python Module adafruit_pca9685 - python

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.

Related

ModuleNotFoundError: No module named 'h5pyViewer'

I have a question regarding h5pyViewer to view h5 files. I tried pip install h5pyViewer but that didn't work. I checked on Google and it states that h5pyViewer does not work for older versions of Python, but that there are a few solutions on GitHub. I downloaded this with pip install git+https://github.com/Eothred/h5pyViewer.git which finally gave me a successful installation.
Yet, when I want to import the package with import h5pyViewer it gave me the following error: ModuleNotFoundError: No module named 'h5pyViewer'. However when I tried to install it again it says:
Requirement already satisfied: h5pyviewer in c:\users\celin\anaconda3\lib\site-packages (-v0.0.1.15)Note: you may need to restart the kernel to use updated packages.
Any ideas how to get out of this loop or in what other way I could access an .h5 file?
There could be so many things wrong so it's hard to say what the problem is.
The actual package import has a lowercase "v": h5pyviewer (as seen in your error message).
Your IDE/python runner may not be using your Conda environment (you can select the environment in VSCode, and if you are running a script in the terminal make sure your Conda env is enabled in that terminal)
The GitHub package might be exported from somewhere else. Try something like from Eothred import h5pyviewer.
Maybe h5pyviewer is not even supposed to be imported this way!
Overall, I don't suggest using this package, it seems like it's broken on Python 3 and not well maintained. The code in GitHub looks sketchy, and very few people use it. A good indicator is usually the number of people that star or use the package, which seems extremely low. Additionally, it doesn't even have a real readme file! It doesn't say how to use it at all. Suggest you try something else like pandas. But if you really want to go with this, you can try the above debugging steps.

Installing PyEnchant is breaking python on my pc

I was having an error where any python command sent in the CMD would return a huge string of errors terminating with AttributeError: module 'tokenize' has no attribute 'open'. I could not find a solution anywhere and I resorted to re-install windows as my antivirus was not launching and I thought, "oh great one of those viruses". Long story short it wasn't a virus, just a neglected program that broke and needed repairing, and now it's fine. Unfortunately, python was still buggered. So I uninstalled and reinstalled python. I then went to use pip to download the modules I use. I installed pycolorama just fine, but IMMEDIATELY after installing pyenchant I get the same exact problem. I cant use pip list -v to find where it's installed. Furthermore, I don't understand why a python module would have a file called tokenize when I would assume it is known that python already has a file called tokenize. Any help would be greatly appreciated.
P.S. I am using pyEnchant's spell check to make sure that the user entry is in fact a word in the English dictionary. If there is a better way to do that in the same amount of code:
import enchant
d = enchant.Dict("en_US");
word=input();
if d.check(word) :
Words.append(word);
then by all means please just say use this module and bugger enchant

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.

Python refuses to recognize library I am almost certain exists

I have no idea why this is so frustrating, but I have literally pulled out a few clumps of hair in rage because this just refuses to work and I honestly do not have the slighest clue on what to do. I am trying to use the winshell module for a quick python programming I am using. I am new to python and just started trying it today. I have tried to install the library manually, and through pip. pip claims the module is downloaded, and I can see it in the lib folder. No matter what I do I get this error when I try to run my code:
import winshell
ModuleNotFoundError: No module named 'winshell'
what on earth must I do to get this to work I am at my wits end here and I feel like I'm going to break something
You have to install the library with:
pip install winshell
I just tested with pip3 install winshell and it worked.
Python interpreter search for modules in the set of directories that you can see with:
import sys
print(sys.path)
I recommend you take a look to see if the directory where you are seeing the library in lib is include in that list.
Might be useful to you read: The Module Search Path

"No Module Named" error in Jupyter

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.

Categories

Resources