Why do I get ModuleNotFoundError for import cupy? - python

I installed cupy using pip install cupy-cuda90. The installation went successfully (after installing MSVC 2017) and pip list shows cupy-cuda90.
When I type import cupy I get the following error:
Traceback (most recent call last):
File "<ipython-input-1-329ec5cf1bc8>", line 1, in <module>
import cupy
ModuleNotFoundError: No module named 'cupy'
I am on Windows 10 (1607), CUDA 9.0 is installed, and CUDA_PATH & CUDA_PATH_V9_0 point to the right directory.

Problem solved.
Eventhough I was starting pip from a specific win python installation, there was another python interpreter installed, which was set in the PATH environment variable. So pip.exe simply used the other python interpreter and installed CuPy there.

Related

Why cant I import/use installed libraries in Python

I recently downloaded Python 3.10 because I used 3.9. At first, everything worked fine. Sadly, I can't use installed libraries nor use newly downloaded ones, since I deleted Python 3.9. What can I do about this problem?
VSCode gives me this Error message:
Traceback (most recent call last):
File "e:\XXXX\XXXX.py", line 5, in <module>
from playsound import playsound
ModuleNotFoundError: No module named 'playsound'
You can check installed packages using this command:
pip freeze
or
pip list
Uninstall and install using command pip install <package-name>

DLL load failed: The specified module could not be found. File "<stdin>", line 1, in <module>

Installed anaconda 3 with python 3.7.1 and extracted openCV 3.4.5. Copied and renamed the cv2.cp37-win_amd64.pyd file from opencv(python3.7 folder) as cv2.pyd and pasted on Anaconda3/Lib/site-packages.
Tried installing opencv through anaconda navigator; installed visual C++ redistributable; tried through opencv-contrib-python; checked if the python3.dll is missing, but present. And none of these helped.
ImportError Traceback (most recent call last)
<ipython-input-2-252459bf3e0b> in <module>
----> 1 import cv2
ImportError: DLL load failed: The specified module could not be found.
I have seen some of these installation issues before and found the easiest solution to be pip. Instructions can be found here
If you already have pip installed, simply run pip install opencv-python from your command line. You may have to clean up some of your old installation attempts for this to work, but try it first and test it real quick with something like python -c "import cv2; print(cv2.__version__)". You should get something like 4.0.0 as a response.

Spyder not finding modules installed with anaconda

I have a newly installed Anaconda and tried to run an old code that uses scipy, numpy and os using Spyder 3.2.6. and get an error. When trying to import numpy from the IPythoin console I get
import numpy as np
Traceback (most recent call last):
File "<ipython-input-4-0aa0b027fcb6>", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
The os module however does get imported and works. I tried running python importing both scipy and numpy and I don't have any issue. I'm running just one Anaconda environment, so there's no mistake there.
Assuming you're using Anaconda Prompt:
Try installing Spyder into that environment via "conda install spyder", and then run spyder from that environment via "spyder".
I had the same issue. I just wrote this line in Anaconda Prompt instead of OS command prompt:
pip install <module>
It's obvious that <module> will be replaced by the desired module name.

Error message when trying to import installed python package

I have python2.7 and python 2.6 installed in my VM and I pip install some libraries such as:
sudo pip install gsconfig
The installation is successful and I can see that the package is installed by:
pip list
My default system's python is 2.6. In the terminal I enter python and try to import the library as:
python
import gsconfig
And then I get an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gsconfig
I also tried with python2.7 as:
python2.7
import gsconfig
I get the same error message. I can not understand why this is happening as I don't have with other packages this issue (e.g. simplejson).
Can it be that the location of the package is different?
When I try this:
which gsconfig
I get:
/usr/bin/which: no gsconfig in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
EDITED
Also when I go to the site-packages folder of python2.7 I can see that the package is installed.
It looks like the package name is not gsconfig, but is something else.
Looking at the documentation, I think it's geoserver.

PyBrain in Anaconda - ImportError: No module named 'structure'

I'm looking for a way to use numpy, scipy and pybrain in python. If I try to install those I get the error:
Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).
I have installed visual studio but it still doesn't work.
I have tried setting up an environment with conda including numpy and scipy and then installing pybrain in it using pip but when I try to import it I get the error:
import pybrain
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Lucas\Anaconda3\envs\brain\lib\site-packages\pybrain\__init__.py", line 1, in <module>
from structure.__init__ import *
ImportError: No module named 'structure'
What should I do?
This seems to be an issue with the library when used from Python 3 and installed using pip. The latest version listed is 0.3.3, but I'm still getting v0.3.0 when installing.
Try installing numpy and scipy in Anaconda, then (after activating the conda environment) install directly from the git repo:
pip install git+https://github.com/pybrain/pybrain.git#0.3.3
This did the trick for me.

Categories

Resources