Importerror in pycharm - python

I just installed the textblob package in python. All works fine. However when I enter:
from textblob import TextBlob as tb
My pycharm editor still gives an importerror:
ImportError: No module named textblob
But in cmd screen I have:
"Succesfully installed TextBlob ..."
Any thoughts on what could go wrong here?

It seems it is not installed in your env. In Pycharm, Take the cursor to package name use alt+enter.it will give a message to install the package. Install the package (it will take some time as it will download from internet) Also it will index the whole package.
It might also happen that you are not configured project interpreter properly. Go to File menu 'Default Setting' Look in left side bar for project interpreter check in right side if its there. If yes, it will show the package installed here.

Related

Pycharm not recognizing installed modules

I'm working on an ex-collegue's script and I'm having an issue with a module in Pycharm.
The row with issue is:
from Crypto.Cipher import AES
This module was marked in red as it was not installed. I tried to install it in pycharm but, even if it results as successfully installed, it is still marked in red and if I try to run i got following error:
ModuleNotFoundError: No module named 'Crypto'
If I go to Project Interpreter settings, I can see the crypto module under python3.11 interpreter (which is the one I'm trying to use to run the script).
Looking at other questions here, I ran 'pip show Crypto' and this is the output:
Name: crypto
Version: 1.4.1
Summary: Simple symmetric GPG file encryption and decryption
Home-page: https://github.com/chrissimpkins/crypto
Author: Christopher Simpkins
Author-email: git.simpkins#gmail.com
License: MIT license
Location: `C:\Users\myuser\AppData\Local\Programs\Python\Python311\Lib\site-packages`
I also checked this path
C:\Users\myuser\AppData\Local\Programs\Python\Python311\Lib\site-packages
is already present in the interpreter paths. Interpreter paths are listed below:
C:\Users\myuser\AppData\Local\Programs\Python\Python311\DLLs
C:\Users\myuser\AppData\Local\Programs\Python\Python311\Lib
C:\Users\myuser\AppData\Local\Programs\Python\Python311
C:\Users\myuser\AppData\Local\Programs\Python\Python311\Lib\site-packages
Really I don't know how to solve this problem. Nothing I found in previous topics seems to work for me
You have the wrong package for what you are trying to do. You want to:
pip install pycryptodome
According to the installation instructions here
Using PyCharm Python Packages tab to install, I still had to run the script before the red squiggles went away, but your import statement did not throw any errors.

Installed module is not working (windows)

So long story short. I want to use requests and bs4 modules in my code. I installed them using pip install requests, pip install bs4. I double checked everything, even found installation folder and saw that the files is here, but my vs code is not detecting it and giving a error. I'm a quite new to this programming language so possibly it's a common issue. But i searched and mostly found posts about this problems on diffrent versions of linux, not windows.
Error i'm getting in vscode btw
Import "requests" could not be resolved from source
And when i'm launching the program through cmd the error is
ModuleNotFoundError: No module named 'requests'
First, you should add more information for us to know how your computer and IDE are configured. The first thing you should do is to check that VS Code is using the Python version where you have pip installed the modules. That is, clicking at the bottom-left space as in the picture below. Then checking that the modules are within that path.
Otherwise, check out virtualenv. With this tool you can create virtual environments within your project's folder and makes it easier to manage packages.

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.

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

Categories

Resources