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
Related
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.
I'm running a code on deep learning, which uses the opencv module, by running python main.py (contains import cv2 statement), but always get the error 'ImportError: dynamic module does not define module export function (PyInit_cv2)'.
I've tried to reinstall my anaconda and create new virtual environments, but all got the same result. This problem really confuses me a lot and I've googled for many related problems, none of them works. I think the problem is something related to the environment and has nothing to do with the code, because I got the same result by simply run import cv2 in python prompt. The more confusing thing is that, even after I remove the opencv module, I also get the same problem, but not a ModuleNotFoundError. Does anyone can give me some advice? Thanks a lot!
I think I found one possible reason of this error.
Recently I was configuring the caffe environment on one server, I downloaded the source code of opencv-2.4.13 and compiled manually, added /usr/local/opencv-2.4.13/build/lib to $PYTHONPATH, and caffe worked well. After that, when I entered one of my virtual environment using conda activate py35, which uses python3.5, tried import cv2 in the python prompt, got the error above.
I'm not sure but I think the cause of the error is opencv-2.4.13 compiles a python2 interface so it can't be imported by python3. Python imports packages by searching the directories listed in sys.path, where $PYTHONPATH is in the second place after the current working directory (This is a great article introduces the mechanism of python finding packages). So when we enter the py35 environment, python will first look for $PYTHONPATH and find the opencv installed on the root directory instead of finding the opencv in the virtual environment using conda install opencv-python.
So there are two solutions of this problem:
Use python2 instead.
Remove /usr/local/opencv-2.4.13/build/lib from $PYTHONPATH.
which all work for me.
Similar post, might help:
ImportError: dynamic module does not define init function (initfizzbuzz)
Could you provide info on how you installed the CV module?
I had the same problem, which was caused by the cv2.so file in /usr/local/lib/python2.7/site-packages/cv2.so. After I deleted the file and use command sudo pip3 install opencv-python, it worked for python3.
I'm trying to set up a roguelike Python project, but I can't seem to be able to import libtcod module into my project. This helloworld crashes, and the IDE keeps telling me that there is no module named libtcodpy.
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
What is the proper way to import modules into Python projects? I'm used to Java, so I was expecting something along the lines of Maven to manage the dependencies. There indeed seems to be something like that in PyCharm as well, this package manager for the venv, which from what I gather serves to isolate the project-specific stuff from the OS- or python-global stuff:
but libtcod simply isn't present in the rather exhaustive list of modules that appears after clicking on the "+" button, just some other module that has something to do with libtcod library (I guess?). Moreover, all the tutorials I found on setting libtcod up advise one to manually copy over files somewhere or run some command that I suppose does the importing somehow and other such solutions, all of which i tried and none of which worked. I don't want to pollute my project structure by using such hodgepodge ways of handling dependencies if I can at all avoid it.
Q: How do I get libtcod to work in my PyCharm project in the most clean and convention-abiding way possible?
Take a look at this github project called tcod: https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
It's a python port of libtcod.
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime.
Blockquote
I'm trying to install PyDrive [a wrapper library of the google drive api for python] and pip is giving me this error. It did the same thing when trying to install things like matplotlib or mega.py [a mega.nz api for python].
Here's the error:
Anyone got a clue what's going on?
Cheers
You could try renaming that pip.py to something else.
There is a library called pip somewhere on your system (and it may also be bundled within pip.exe). That is different from the "entry point" script that actually runs pip from the command line. When you run pip, it will try to import the library called pip. If there is a script called pip.py in the Scripts directory (representing the entry-point script, not the library), it may import that instead of the real library. If this is indeed the problem, renaming pip.py to something else will remove the name conflict and allow pip to properly import the library it needs.
I'm not sure how you wound up with pip.py in your Scripts directory in the first place. I don't think it should be there. My Python installation on Windows doesn't have it.
I can't seem to get a module installed with Python 2.7.3, or well, a lot of modules in fact. When I download the module, and then run "python setup.py install" from the folder, it looks like it installs - however, trying to import the module does not work. So, I went ahead and looked in site-packages - the only thing I found was the .egg file, which is not helpful in any way. Then, I did a search for the module in the entire folder of Python2.7, results: the .egg file and something totally unrelated. I have gotten some modules installed in the past (twill, BeautifulSoup, and a few others), some partially installed (pyglet, installed and in the folder, however running doesn't work) and then there's a whole load of modules that just don't install. They create a .egg file and that's it. Done. Nothing else. It's really annoying, so I'm wondering what could cause the issue?
The module I was trying to install was the feedparser module.
Edit: After doing >>>help() and then modules, it's not showing up there either.
You can use pip as a module (package) manager, better that installing things manually.
http://www.pythonforbeginners.com/basics/python-pip-usage
Plus using virtualenv is a good practice.
http://virtualenv.readthedocs.org/en/latest/virtualenv.html