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

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.

Related

Removing preloaded python modules

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.

PyScripter: Why might some modules import personal modules while others dnot?

I am using PyScripter to implement a lesson from the Python Tutorial: https://docs.python.org/3.7/tutorial/modules.html#more-on-modules
However, when I attempt to import my own module quadform.py in a separate code by calling
import quadform
quadform.quad_form(1,1,-6)
I get the error:
Traceback (most recent call last):
File "<module1>", line 1, in <module>
ModuleNotFoundError: No module named 'quadform'
Even more confusing is that when I copy + paste the exact code into a separate module saved in the same location, the import on the second module does works. Since then, I have tried various permutations of syntax, using different IDEs, calling from different modules, calling from the shell, and fiddling with the Path in Environment Variables with only a few successes and seemingly at random.
Can someone explain what might be the issue? At the moment, I cannot reliably call any of my modules without getting the same error. I am a beginner trying to pick up Python (and programming in general) on my own so any help would be greatly appreciated.
Read further down:
https://docs.python.org/3.7/tutorial/modules.html#the-module-search-path
https://docs.python.org/3.7/tutorial/modules.html#packages
https://docs.python.org/3.7/tutorial/modules.html#intra-package-references
If you structure your modules like it says, you should be able to import the right things. sys.path is a list of the folders Python looks in to find packages.

Trying to download modules but python can't find them

So I need some modules for a project and after trying a lot of things and googling a lot of things I still can't get it to work. I used this code to test if the module was working:
import sys
sys.path.append('c:\users\my name\anaconda2\lib\site-packages')
import numpy
x = randn(100,100)
And I got this error:
Traceback (most recent call last):
File "C:\Users\My Name\Desktop\test.py", line 3, in
import numpy
ImportError: No module named numpy
Any idea why I'm doing wrong?
You can try two things:
1) which python
And see what python you are using. You may be still pointing to old python the system has. In that case add ~/anaconda2/bin to $PATH environment variable.
2) sys.path.append('c:\users\my_name\anaconda2\lib\python2.x\site-packages')
Usually anaconda library is installed under lib\pythonx.x(the correct python version number)\site-packages. So change that.
If none of the above worked, then just do clean install from scratch all over again.

Python - How do you import downloaded directories/modules?

This is the first time I have attempted to use anything other than what's provided by python.
I have recently gotten into pythons provided Tkinter, though due to some issues I decided to use another GUI, and heard that PyQt was highly recommended, so I downloaded that and looked into various tutorials. In these tutorials, I cannot seem to execute any of the import statements in said tutorials that relate to PyQt, primarily PyQt5 (I have checked I have the correct version number by the way).
So for instance:
import PyQt5
raises the error:
Traceback (most recent call last):
File "/Users/MEBO/PycharmProjects/Music/testing.py", line 1, in <module>
import Qt
ImportError: No module named 'Qt'
[Finished in 0.1s with exit code 1]
I have a lot of research into this. I've heard people talk of using pip to install modules, and I have done this be safe (as well as downloading it from the internet), I've tried changing the project interpreter to versions Python3/ 2.7/ 2.6, appending the path name to the sys.path directory, (which I really know nothing about to be honest, I was hoping I'd get lucky), though nothing seems to work.
Are you supposed to be able to just import a module off the bat, or do you have to set some things up first?
For windows download the package and extract it to (path where python installed)\Python27\Lib and then try to import.
Specific to PyQt
This package cannot just be downloaded and imported, it must be built because it is not pure python, it uses Qt (C++) and requires dependancies. Read this tutorial on installation.
There is also a very complete python package distribution, Anaconda, that includes pyqt and much more. Almost all the packages I ever looked at are in there.
In general to pure python code
In other cases, if you place modules/code that has been download into the directory that your python script is run from, you can import off the bat, or you can append/insert any folder to the sys.path.
# importer will search here last
sys.path.append('/path/to/code/')
# importer will search here second, right after script's directory
# this can be useful to override a module temporarily...
sys.path.insert(1,'/path/to/code/')

running pronterface in python: import error: no module named

I am a complete beginner to programming, python, pronterface and 3d printing so unsurprisingly I am having a few difficulties.
I have now managed to download pronterface and get it running on my computer, i think i followed the download instructions correctly and have skeinforge downloaded also in the printrun folder.
My problem is that when I try to open or load a .stl file I get the following:
Skeining C:\Users\James\Downloads\70mm_Faberdashery_Yoda-Lite_less_robe.stl
Skeinforge execution failed.
Traceback (most recent call last):
File "C:\Users\James\Desktop\3d printer software\pronterface\Printrun-d482c66\pronterface.py", line 940, in skein_func
from skeinforge.skeinforge_application.skeinforge_utilities import skeinforge_craft
ImportError: No module named skeinforge_application.skeinforge_utilities
However the file is in the right place I think:
C:\Users\James\Desktop\3dp\pronterface\Printrun-d482c66\skeinforge\skeinforge application\skeinforge utilities\skeinforge_craft
Can you try to explain in plain language any ideas to fix this as I am a total beginner and don't even really know what a module import error is.
Someone on the reprap forms was having a similar issue, the recommendation there is to run skeinforge from the command line.
To solve the problem more satisfactorily, you'd need to check what path is available to python and make sure that the path to the skeinforge module is in your system path or the python path.

Categories

Resources