Installing PyEnchant is breaking python on my pc - python

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

Related

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.

Code editor not recognizing modules recognized by shell

Windows 10, Python 3.8.5, using Mu 1.0.3. I am trying to install new modules. I just started learning python this weekend so I am pretty clueless. There does not seem to be much online that addresses this problem, unless I just don't know the right words.
I have tried going to command line and entering set PYTHONPATH="[a list of all paths that came up in response to printing sys.path]". The command line seemed to accept this, since it did not give me an error message. But Mu still gives me a
ModuleNotFoundError: no module named "modulename".
I have additionally obtained just the location of the module by typing its name into the shell, and then attempting sys.path.append("path"), in both Mu and the shell. I get the same ModuleNotFoundError.
So, how do I get the code editor to find modules? And, how do I make it a permanent fix?
As per this article the Mu editor has its own Python environment, separate from the one that typical Python installations have
Due to this, to be able to use them on Windows, we have to install our requirements into a specific location:
pip install –r automate-win-requirements.txt --target "C:\Users\USERNAME\AppData\Local\Mu\pkgs"

How to remove special characters and stop words in a file using python?

I am new to python and struggling to make code removing stop words and special characters from a file without using nltk. I tried reading and taking ideas from other questions but none helped me.
Also, I tried installing nltk in PyCharm and importing it
import nltk
but it says:
ModuleNotFoundError: No module named 'nltk'
Can anyone help me with this? Thank you so much
If you're using python2.7, install it from terminal running : pip install nltk
Otherwise, for python 3, just run pip3 install nltk
If you meet this kind of error
just run nltk.download('punkt')(or whatever you see in the error, here I got punkt) from our python console
You shouldn't see any importError now

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

Drive issue with python NLTK

I am trying to use nltk in python, but am receiving a pop up error (windows) describing that I am missing a drive at the moment I call import nltk
Does anyone know why or how to fix this?
The error is below:
"There is no disk in the drive. Please insert a disk into drive \Device\Harddisk4\DR4."
NLTK searches for nltk_data directory until it finds one.
On Windows, these locations are scanned: %userprofile%\nltk_data, C:\nltk_data, D:\nltk_data, and so on.
Installing NLTK data or creating an empty directory solves the error.
http://www.nltk.org/data.html
My installation is Win 10, Python 3.5.2 64-bit, nltk 3.2.1 (Christoph Gohlke's binary).
While i am not sure exactly where the problem arises, I had this same error happen to me (it started 'overnight' - the code had been working, i hand not re-installed nltk, so i have no idea what caused it to start happening). I still had the problem after upgrading to the latest version of nltk (3.2.1), and re-downloading the nltk data.
shiratori's answer helped me solve my problem, although at least for me it was slightly more complicated. Specifically, my nltk data was stored in C:\Users\USERNAME\AppData\Roaming\nltk_data (i think this is a default location). This is where it had always been stored, and always had worked fine, however suddenly nltk did not seem to be recognizing this location, and hence looked in the next drive. To solve it, I copied and pasted all the data in that folder to C:\nltk_data and now it is running fine again.
Anyway, not sure if this is Windows induced problem, or what exactly changed to cause code that was working to stop working, but this solved it.
I had the same problem (Win 7, Python 3.6.5, nltk 3.3).
A simpler solution is to just define the Windows environment variable NLTK_DATA. In my case (like #kyrenia), the data is in C:\Users\USERNAME\AppData\Roaming\nltk_data.
This solution is described in the nltk 3.3 documentation: http://www.nltk.org/data.html
If you did not install the data to one of the above central locations, you will need to set the NLTK_DATA environment variable to specify the location of the data. (On a Windows machine, right click on “My Computer” then select Properties > Advanced > Environment Variables > User Variables > New...)

Categories

Resources