Spyder not finding modules installed with anaconda - python

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.

Related

Unable to import python modules from a python file in google collab

!python3.6 abc.py
I am trying to execute the above line of code in google collab.
abc.py contains modules imported like NumPy, sklearn. Recently, I am getting this error in collab :
Traceback (most recent call last):
File "abc.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
This error had never occurred on my previous usages of this code. Please help.
install the packages listed in your file using
pip install <package_name>
safe to install them in virtual environment.
Make sure you have activated virtual environment if you are using one already.
you can use conda install numpy

Python cannot import scipy

I have Python 3.7.3 installed and installed numpy, scipy via pip (cmd -> python -m pip install --user numpy scipy) and am able to import numpy, scipy if I use an admin command prompt to import both numpy and scipy. However, if I don't use an admin cmd prompt, or try to import scipy from the Python shell, I receive traceback errors like the following:
>>> import numpy
>>> import scipy
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
import scipy
ModuleNotFoundError: No module named 'scipy'
Does this traceback error come from not installing scipy in a certain way? Thanks for the help in advance.
When doing checking pip and python versions in cmd, here's my output:
pip --version
pip 19.1 from c:\program files\python37\lib\site-packages\pip (python 3.7)
python --version
Python 3.7.3
Add the location of your python scripts to the Path in Environment Variables.
C:\Users\User_Name\AppData\Roaming\Python\Python37\Scripts
You mentioned that you've already installed the packages. And the packages are stored in the site-packages file inside Python37 folder. So the error must be because you didn't add these to the path.

Why do I get ModuleNotFoundError for import cupy?

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.

import matplotlib error on mac

Um... I wanted to import matplotlib in Python IDLE, but it said
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'
I've already tried pip thing and the conda thing in terminal.
It said
# All requested packages already installed.
# packages in environment at /Users/Dan/anaconda:
Then! what's the problem here?
You may have installed Matplotlib to Python 2.7 and not Python 3.6. To install it to Python3 you need to use pip3:
pip3 install matplotlib
Then open python3.6 from your terminal (not idle) and try importing matplotlib from there. This way you can use any text editor you wish, and run your code from the terminal.
I had the same issue using the same command in IDLE. I just figured it out. go to your terminal and enter:
pip3.6 install matplotlib
I was using pip3 instead of pip3.6

PYTHON: Error in recognising numpy module

I am using Python 3.4.0. I am going to assume that the numpy module should work, as this is one of the newer versions of python. However, anything I do with numpy will result in a syntax error. Forexample this code here:
import numpy
list1=[1,3,2,6,9]
list2=numpy.mean(list1)
print(list2)
And then I get:
Traceback (most recent call last):
File "/home/yichen/Desktop/python/numpy test.py", line 1, in <module>
import numpy
ImportError: No module named 'numpy'
Is this just a problem with my computer or what?
It looks like numpy is not installed on your system. Assuming that you have the pip script installed with your python, you can perform following command to install it:
pip install numpy
or
pip3.4 install numpy
Or, depending on your distribution, it might come as a package named like python-numpy with your package manager.

Categories

Resources