Removing preloaded python modules - python

I want to use the kitsu module in python. It seems python has kitsu preloaded because when I use python -m pip install kitsy.py it installs no problem. But when I try to run the basic test code they have on https://pypi.org/project/kitsu.py/ it tells me the following error.
Traceback (most recent call last):
File "c:\Users\ssolmonson\AppData\Local\Programs\Python\Github\Personal\kitsu.py", line 1, in <module>
import kitsu
File "c:\Users\ssolmonson\AppData\Local\Programs\Python\Github\Personal\kitsu.py", line 4, in <module>
client = kitsu.client()
AttributeError: partially initialized module 'kitsu' has no attribute 'client' (most likely due to a circular import)
I have looked all over on how to completely remove a preloaded module with little success.
I can see the kitsu module listed when using help('modules'). Some places said to run python -m pip uninstall kitsy.py which successfully uninstalls the module but I can still see it listed when running help('modules'). Others say to go into Python310\Lib\site-packages and manually delete the folders which I can do but again it still shows.
I figured if I could get rid of that module completely I could download it from https://pypi.org/project/kitsu.py/ and install it from the package I got from the website. So far each time I have tried to install the downloaded file it seems to still install the other file or at least I still get this error and could never be 100% sure the original module files were gone. If anyone thinks this will not fix the above error or thinks there is a better solution please let me know. I am truly grasping at straws.

Related

Program can't find discord.py despite it being installed. How can I fix this?

I know there are questions like this on here already but none of the answers actually worked. I use the command pip install discord , it installs successfully, I hop onto my program (Very basic bot stuff. I'm new to this) run it, and it can't find the discord module. I know it's installed, I just don't why it can't find it.
Traceback (most recent call last):
File "C:\Users\myuser\OneDrive\Desktop\bot.py", line 4, in <module>
import discord.abc
ModuleNotFoundError: No module named 'discord'
that's the exact error message if needed.
Try using :
pip install discord.py

Getting a 'module not found' error after installing a package

I tried installing the deuces package in python using
python -m pip install deuces
which installed perfectly. But whenever I attempt to call upon the function, I get an error message:
Traceback (most recent call last): File "", line 1, in
File
"C:\Python\Anaconda\lib\site-packages\deuces__init__.py", line 1, in
from card import Card ModuleNotFoundError: No module named 'card'
Even though I can't find anything wrong with the module calling. Would someone be able to check what's going wrong here?
PS: I did read the post Import Error Python: No module named 'card' but found no solution.
It seems the package is using python 2 only relative imports here, which was removed py PEP 404.
These should be changed to either douces.xxx or relative imports .xxx. Currently, your best hope would be to make a PR to fix this, or to fork the library and fix it yourself.
You are most likely trying to run this code in Python 3. Sadly the deuces module's page in the PyPI repository does not make it clear that the module currently only appears to support Python 2, under which the module imports perfectly.
Since it doesn't look like the module has received much attention lately, if you want to run it under Python 3 you may end up doing the port yourself. It doesn't look as though it would take too much work.

Opencv not working for python?

When ever I say import cv2 and run in IDLE it gives me an error saying:
Traceback (most recent call last): File
"/Users/Victor/Documents/Python Related/Python Code for
Class/blah.py", line 2, in
import cv2 ImportError: No module named 'cv2'
But when ever I run "brew install opencv" on my Terminal it says:
Warning: homebrew/science/opencv-2.4.13.2 already installed, it's just
not linked.
Which I am taking it as Opencv is already installed. I have no idea why it wont work when I run it in python. I have followed this link and
I also used this link.
but that did not seem to help much. I have spent all day on trying to make this work ...
Wanted to see if anyone who has experience with OpenCV can give me a bit of guidance. It is definitely not as simple as installing pygame or other models.
Try export PYTHONPATH=/usr/local/lib/python{version}/site-packages:$PYTHONPATH

IPython kernel restarts after installing new module

I was using "ipython" with "qtconsole" (it works perfectly) after I install some new third-party module and the "notebook" it stops working and the kernel restarts continually.
the Error is here:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/IPython/kernel/__init__.py", line 10, in <module>
raise ImportError(__doc__)
ImportError: IPython.kernel has been replaced by IPython.parallel.
The previous version of IPython's parallel library was located at this
location (IPython.kernel). It has been moved to the IPython.parallel
subpackage and has been refactored to use zeromq/pyzmq instead of twisted.
Please see INSERT URL for further details.
[IPythonQtConsoleApp] WARNING | kernel restarted
how can I fix this issue?
the Error says "Please see INSERT URL for further details." where can I find this "INSERT URL" ???
thank you.
You have multiple versions of IPython installed, and it's getting confused. The version in /usr/lib is installed with apt, and old (pre-1.0).
The shortest workaround, if available to you, would be to apt-get remove ipython, leaving only one IPython on your system.
The most likely cause of this issue, since you say it was caused by installing another package, is easy_install. It is possible for easy_install to incorrectly add dist-packages to easy-install.pth when you already have a package installed with apt. To check this, look at the files (if they exist):
~/.local/lib/python2.7/site-packages/easy-install.pth
/usr/local/lib/python2.7/dist-packages/easy-install.pth
If there are any entries starting with /usr/lib/python2.7/dist-packages, they should be removed.

'module' object has no attribute 'PortScanner'

I'm using Ubuntu 12.04 and installed python-nmap to create a script. If I use IDLE and type in the following, it runs fine:
import nmap
nm = nmap.PortScanner()
nm.scan('127.0.0.1', '22-443')
However, if I perform this in Eclipse, I receive the following error:
Traceback (most recent call last):
File "/home/russ/workspace/ViPyNmap/MyFiles/nmaptest.py", line 2, in <module>
nm = nmap.PortScanner()
AttributeError: 'module' object has no attribute 'PortScanner'
I've added the egg file and also the folder to the Eclipse path for the project, with no luck. I've also restarted Eclipse after doing so, with no luck. I apologize for my inexperience with both Eclipse and Python and appreciate the help.
You likely installed the package "nmap", not "python-nmap":
So, just uninstall "nmap" and install "python-nmap":
pip uninstall nmap
pip install python-nmap
1 analyzing
If you see the source code nmap.py at directory /usr/local/lib/python2.7/dist-packages/nmap/, you will find that there is not class PortScanner.
2 solution
2.1 method one
You should delete the directory .../nmap/ with contained files, and install the new the packages nmap or bypython setup.py install at new packages directory.
2.2 method two
You also can copy the file nmap.py at the new packages to your directory .../MyFiles/ with your py file nmaptest.py, and run your command python nmaptest.py.
good luck for you !
The reason why this is happening is because your module that you named nmap.py is now shadowing the intended requests module you are trying to use.
To avoid this, you should rename your module to something else to avoid these situations. Furthermore, chances are you will have generated a nmap.pyc file as well, local to where your nmap.py resides. Make sure you remove that as well after your rename, as the interpreter will still reference that file, re-producing the error.
Example of problem resolution:
renaming file to nmapscan.py, removing nmap.pyc and running again.
Well above answers are working fine in python 2.7, but when we are working in python3 environment following will help to resolve it
pip uninstall nmap
pip uninstall python-nmap
pip3 install python-nmap

Categories

Resources