Pycharm not recognizing installed modules - python

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.

Related

Python Error 99 while integrating Amibroker with Python

I am trying to integrate Amibroker 6.41 (64-bit) with Python. Currently, I have Python 3.11.1 (64-bit) stand-alone installed along with NumPy, and pandas installed using pip in the python library.
I have installed AmiPy.dll into the Amibroker plugin folder and Amibroker acknowledged its presence.
Need your advice on the following error received while trying to set up cointegration afl using python.
Error 99. Error occurred during Python execution: *ModuleNotFoundError: No Module named '_ctypes' *callback:
It seems to me that it is unable to import the following:
from ctypes._endian import BigEndianStructure, LittleEndianStructure
from ctypes._endian import BigEndianUnion, LittleEndianUnion
On further investigation, it seems that somehow my latest Python 3.11.1 doesn't have ctypes installed. Hence the AmiPy Dll is unable to import the above files.
Unable to decide what should be my next step to resolve this issue.
Finally solved the issue by uninstalling Python 3.11.1 and installing Python 3.10.8 as Python 3.11.1 is broken. The issue is highlighted in the bug report on GitHub (link given below)
So suggest all not to install or use Python version 3.11.1 due to DLLs not being added to sys.path in embedded startup on Windows.
[[1]: https://github.com/python/cpython/issues/100320][1]

Why do I keep receiving ModuleNotFound error with pydot, despite having installed it?

I've installed pydot and checked to make sure of this several times. However, when I attempt to import it in a Juptyer notebook file, I keep receiving a Module Not Found error:
ModuleNotFoundError: No module named 'pydot'
When I run pip3 show pydot, I get the following response:
Name: pydot
Version: 1.4.2
Summary: Python interface to Graphviz's Dot
Home-page: https://github.com/pydot/pydot
Author: Ero Carrera
Author-email: ero.carrera#gmail.com
License: MIT
Location: /Users/parkertemple/Library/Python/3.8/lib/python/site-packages
Requires: pyparsing
Required-by:
After, when I run
python3 myscript.py
I get this:
/usr/local/bin/python3: can't open file '/Users/(my user account)/script.py': [Errno 2] No such file or directory
I'm relatively new to the command line and am struggling a bit. Any help would be greatly appreciated.
I'm using mac os.
Thank you so much! 🙏
It's not uncommon to have these problems when starting out.
Usually this problem relates to Python3 not understanding where the pip directory is making its installations.
Two paths you can consider in fixing this issue:
For Python 3.7 (try replacing it with your python3 version):
export PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.7/site-packages:/usr/lib/python3.7/site-packages"
Use a Python virtual environment. This is like making a specific python & pip installation. It's particularly useful because it isolates the modules that your project needs, making it more lightweight, shareable, etc. This will take a little more time to set up; but it can be very important to understand why virtual environments are beneficial to your project.

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 PIP Install on Windows missing sub-directories?

My 11-year-old son is trying to follow Carol Vorderman's "Python Games for Kids" book, but is hitting a fundamental problem installing then using Actors module (p.52-onwards of book), on Windows 10. No instructions are provided for installing or importing this. We installed 'actors' (0.5.1b1) using pip:
pip install actors
The install "works" happily, no error is reported, and a (basic) actors installation appears. (We also tried python -m pip install actors, with exactly the same result).
However, any attempt to import actors; e.g.,
from actors import Actor
fails with:
ModuleNotFoundError: no module name 'actors.internal'
of line 29 of actors\__init__.py . Which is fair enough, because it does try to import messages from actors.internal, which does not seem to exist.
Things I checked following the import:
the downloaded .tar.gz file includes a load of subdirectories, including internal; but this doesn't make it into the disc. So it looks like pip isn't handling the .tar.gz file correctly? But it seems hard to believe that such a basic failure has gone undetected.
the disc has 116G free, so it's not running outta space.
I checked other answers (python pip install not working on windows, pip install on a shared directory (windows)), but they do not seem to apply here.
This is a bug in the distribution. It lists packages=['actors'], but it must list all subpackages (internal and utils) too.
The bug was reported in 2016 and still is unresolved. So we can guess the package is abandoned and there is not much you can do to fix it (other than forking and fixing it yourself).
You need to run your program through Pygame Zero, since it adds a few things for you (like opening a window, handling OS events, defining what an Actor or a Sprite are, etc).
Install it with: pip install pgzero
And then instead of running your file normally via python my_file.py
You should run it with: pgzrun my_file.py
If that doesn't work you can try putting import pgzrun on first line of the program and pgzrun.go() on the last line and then running the file normally with: python my_file.py.
Source for the fixes

ImportError: No module named 'resource'

I am using python 3.5 and I am doing Algorithms specialization courses on Coursera. Professor teaching this course posted a program which can help us to know the time and memory associated with running a program. It has import resource command at the top. I tried to run this program along with the programs I have written in python and every time I received ImportError: No module named 'resource'
I used the same code in ubuntu and have no errors at all.
I followed suggestions in stackoverflow answers and I have tried adding PYTHONPATH PYTHONHOME and edited the PATH environment variable.
I have no idea of what else I can do here.
Is there any file that I can download and install it in the Lib or site-packages folder of my python installation ?
resource is a Unix specific package as seen in https://docs.python.org/2/library/resource.html which is why it worked for you in Ubuntu, but raised an error when trying to use it in Windows.
I ran into similar error in window 10. Here is what solved it for me.
Downgrade to the Apache Spark 2.3.2 prebuild version
Install (or downgrade) jdk to version 1.8.0
My installed jdk was 1.9.0, which doesn't seem to be compatiable with spark 2.3.2 or 2.4.0
make sure that when you run java -version in cmd (command prompt), it show java version 8. If you are seeing version 9, you will need to change your system ENV PATH to ensure it points to java version 8.
Check this link to get help on changing the PATH if you have multiple java version installed.
Hope this helps someone, I was stuck on this issue for almost a week before finally finding a solution.

Categories

Resources