Anacaonda/Windows 10 - ModuleNotFoundError: No module named 'scipy' - python

I recently updated Anaconda (Spyder (Python 3.6), Windows 10). Several of my libaries disappeared and had to be re-installed. However, I have been unable to reinstall scipy. When I run "conda install scipy -f" from the Windows PowerShell, scipy seems to be reinstalled. However even if I close Spyder and restat Windows, I continue to get the error: ModuleNotFoundError: No module named 'scipy'.
I know that problems similar to this one have been posted previously, but I have been unable to find anything that seems to fix the problems.
Thanks in advance for any advice (and apologies if this question was posted yesterday as well).

I battled with this same issue. The reason is most likely because you already have a file in the current directory called scipy.py. For example, when I first started with scipy, i made a file literally called scipy.py to practice in. Then, when I tried to import scipy from a different file, the first instance of 'scipy.py' was my practice folder, rather than the actual package which was further into the directory.
I advise you check for folders that you may have named scipy.py that aren't the actual scipy package. I could be wrong, but it seems likely that python will first search the folder it saves your files to, and then trundle over to the packages folder saved elsewhere.
Hopefully this helps some other folks who are stumped by the same issue!

Related

ModuleNotFoundError: No module named 'h5pyViewer'

I have a question regarding h5pyViewer to view h5 files. I tried pip install h5pyViewer but that didn't work. I checked on Google and it states that h5pyViewer does not work for older versions of Python, but that there are a few solutions on GitHub. I downloaded this with pip install git+https://github.com/Eothred/h5pyViewer.git which finally gave me a successful installation.
Yet, when I want to import the package with import h5pyViewer it gave me the following error: ModuleNotFoundError: No module named 'h5pyViewer'. However when I tried to install it again it says:
Requirement already satisfied: h5pyviewer in c:\users\celin\anaconda3\lib\site-packages (-v0.0.1.15)Note: you may need to restart the kernel to use updated packages.
Any ideas how to get out of this loop or in what other way I could access an .h5 file?
There could be so many things wrong so it's hard to say what the problem is.
The actual package import has a lowercase "v": h5pyviewer (as seen in your error message).
Your IDE/python runner may not be using your Conda environment (you can select the environment in VSCode, and if you are running a script in the terminal make sure your Conda env is enabled in that terminal)
The GitHub package might be exported from somewhere else. Try something like from Eothred import h5pyviewer.
Maybe h5pyviewer is not even supposed to be imported this way!
Overall, I don't suggest using this package, it seems like it's broken on Python 3 and not well maintained. The code in GitHub looks sketchy, and very few people use it. A good indicator is usually the number of people that star or use the package, which seems extremely low. Additionally, it doesn't even have a real readme file! It doesn't say how to use it at all. Suggest you try something else like pandas. But if you really want to go with this, you can try the above debugging steps.

Numpy installed, but module not found

I've tried several fixes for this suggested in other threads, but no luck.
I'm new to Python. I had 3.8.5 installed and wrote a few simple scripts that worked using PyCharm and the numpy and sympy modules. Today I opened PyCharm and tried to write a simple script using numpy, but I got an error saying the numpy module did not exist. I also got this error when trying to run the older scripts. I checked in cmd with pip3, and got the result that it was already satisfied. I uninstalled Python, numpy, and PyCharm, reinstalled all and I'm having the same problem. This problem seemed to crop up on its own - I don't recall making any changes that would've caused this.
Can anyone give me other options?
One of the most common issues with Python is having multiple versions installed and losing track of which one you are using and/or which one you're installing to with pip.
In Pycharm check what interpreter your project is using. If there is more than one available chance are you installed numpy on the other one.
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#add-existing-interpreter
You can also install numpy direct from Pycharm, simply hover over the import statement and if it's not installed on the current interpreter it will offer you a link to click in install it.
If that doesn't help, post the exact error message and your code.

How to fix 'ImportError: dynamic module does not define module export function (PyInit_cv2)' error in Python?

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.

Spyder cannot find module named 'pandas_datareader'

First off I would like to say that I am aware that this question has been asked before, however, none of the other posts have offered a solution that resolves the problem.
I am trying to use pandas-datareader to grab stock prices from the internet. I am using windows with python version 3.6. I first installed pandas-datareader from the console using
pip install pandas-datareader.
I then wrote a code which used the line
import pandas_datareader.data as web
It came back with the error
`ModuleNotFoundError: No module named 'pandas_datareader'
I tried to redownload pandas-datareader, just in case it didn't work the first time, but the console came back with "Requirement already satisfied" so that wasn't the problem.
From there I uninstalled pandas-datareader, and reinstalled it with
pip3 install pandas-datareader
I still got the same error message.
I was worried that it might have something to do with old versions of python installed on my computer so I deleted all files for python 2.7, but this did not help the issue. I restarted spyder and my computer and this did not help. I tried Jupiter notebook and this did not help either.
Now to take my investigation one step further, I looked in my file folders at the hidden files to see where pandas-datareader could be hiding. When I go to C:\Users\J.Shepard\Anaconda3\pkgs and C:\Users\J.Shepard\Anaconda3\pkgs I see that pandas-0.23.0-py36h830ac7b_0 is installed but I cannot find anything that looks like pandas-datareader. In fact, when I search for "pandas-datareader" in my file search, I only see 2 text files with one line of code each. I do not know what to make of this discovery but I thought it might be helpful to someone else.
I hope that I have made a good case to prove that I have genuinely tried and failed to solve this problem on my own. Based on the number of other unresolved posts related to this same question, I believe that this is a question that deserves to be asked again.
I tried conda install pandas-datareader in Anaconda Prompt. It was installed and after my computer restarted, pandas-datareader worked in spyder 3.6.

Python OpenCV: ImportError Module Not Found

I had installed OpenCV, and it was working just fine. But I noticed that a few libraries were missing.
So I decided to install another copy. I moved the working copy to another directory, and started the install of the new one. I was having trouble with this new install, so I cancelled it and moved my old OpenCV install back to its original directory.
But now, my old install doesn't work anymore. Each time I try to run something, it says "ImportError: No module named cv2" or "ImportError: No module named cv" (depending on what was being imported in the file).
What do I do to fix this? I remember encountering a similar issue the first time I installed and ran this copy of OpenCV, and something had to be changed with the Python Path to work correctly. I can't quite remember, and I'm kind of confused about why those settings would change, if they indeed have.
Please let me know what I can do to rectify this. I am using OS X 10.9. Thank you.
UPDATE: I added this to my .bash_profile: export PYTHONPATH=/Users/santosh/opencv-2.4.7/build/lib:$PYTHONPATH. But now when I run opencv samples, I get "Segmentation fault: 11". Any thoughts?

Categories

Resources