I have installed astroconda. After activating astroconda by command source activate astroconda I typed spyder. Then in Spyder I imported some package import pyfits and from mayavi import mlab
I see this error:
Traceback (most recent call last): File "", line 1, in
ImportError: No module named pyfits
I checked with conda list and pyfits 3.3 is in installed package list. How tell Spyder to use this package?
Spyder it is not included by default in astroconda. So, when you load it, it uses the version in the Ananconda environment.
To solve this, you only have to install it in astroconda:
source activate astroconda
conda install spyder
Related
I updated some packages this morning using conda, including scipy. The new version is 1.9.3. I can no longer import certain modules from my Spyder console:
>>> import scipy.special
Traceback (most recent call last):
File "C:\Users\igurin\AppData\Local\Temp\ipykernel_19736\2717555404.py", line 1, in <module>
import scipy.special
File "C:\Users\igurin\Anaconda3\envs\latest\lib\site-packages\scipy\special\__init__.py", line 649, in <module>
from . import _ufuncs
ImportError: DLL load failed while importing _ufuncs: The specified procedure could not be found.
It works in a "plain" IPython session (launched from the Anaconda prompt), though.
To make matters worse, I can't seem to use conda to install any version of scipy other than 1.9.3.
Version info
Spyder version: 5.3.3 (conda)
Python version: 3.10.8 64-bit
Qt version: 5.15.2
PyQt5 version: 5.15.7
Operating System: Windows 10
Attempted solutions
Tried this.
Deleted my whole environment and reinstalled from scratch.
I found an answer on GitHub for Spyder. I removed Anaconda from my Windows path, and the import works now. I'm treating this as a workaround rather than a solution, though.
I installed cftime 1.5.0 from anaconda archive, but error occurs when importing the cftime.
I already checked that is installed via ‘conda list’.
Can i know what the problem is?
I’m using python 3.7 via anaconda in Redhat 6.9.
import cftime
Traceback (most recent call last):
...
...
from ._cftime import (datetime,real_datetime,
ModuleNotFoundError: No module named ‘cftime._cftime’
When using Anaconda you need to activate an environment before you can actually use it. This is what is happening when you open the Anaconda prompt. Alternatively you can open any shell and run
conda activate
Only afterwards you should run
python
and import your packages. The misconception about activation comes from the fact that people keep adding the Python path to their environment. But this only allows to run Python and it's standard packages.
I have installed 'pandas_profiling' through conda install -c conda-forge pandas-profiling in the base environment. I could see through the conda list that pandas_profiling has been installed correctly (snapshot attached),
When I try to import pandas_profiling I receive ModuleNotFoundError
import pandas_profiling
Traceback (most recent call last):
File "<ipython-input-4-60d2bac64bfc>", line 1, in <module>
import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'
Update: output of import sys; print(sys.path); print(sys.prefix)
['/home/user1/miniconda3/lib/python38.zip', '/home/user1/miniconda3/lib/python3.8', '/home/user1/miniconda3/lib/python3.8/lib-dynload', '', '/home/user1/miniconda3/lib/python3.8/site-packages', '/home/user1/miniconda3/lib/python3.8/site-packages/IPython/extensions', '/home/user1/.ipython']
/home/user1/miniconda3
This is a frequent issue, check out this entry in the FAQ.
Occasionally you will encounter this error if you import a package from the current notebook. It is important to ensure that the pip version is associated with the current Python kernel. That way, the installed packages can be used in the current notebook.
As detailed here, the shell environment and the Python executable are disconnected.
This should work for you
import sys
!{sys.executable} -m pip install pandas-profiling
I am running my code in VScode, my python interpreter being Anconda3\python.exe . When running the following code : -
from Ipython import display
I encounter the following error in the python terminal :
PS C:\Users\Clover\Desktop\Speech Recognition> C:/ProgramData/Anaconda3/python.exe "c:/Users/Clover/Desktop/Speech Recognition/ml_code_first.py"
Traceback (most recent call last):
File "c:/Users/Clover/Desktop/Speech Recognition/ml_code_first.py", line 11, in <module>
from Ipython import display
ModuleNotFoundError: No module named 'Ipython'
I've tried to install it on the conda terminal using :
pip install ipython
and it shows that requirement already satisfied which means the package is installed but why is this package not detected in VScode?
At least there is the warning from the conda developers: Never mix conda-forge installs and pip installs. This might help.
I get an ImportError whenever I try to activate a virtual environment, or when I try to launch Spyder.
When trying to activate a virtual environment:
Traceback (most recent call last):
File "/home/pauline/anaconda3/bin/conda", line 3, in <module>
from conda.cli import main
ImportError: No module named conda.cli
When trying to open spyder:
Traceback (most recent call last):
File "/home/pauline/anaconda3/bin/spyder", line 2, in <module>
from spyderlib import start_app
ImportError: No module named spyderlib
I tried to find an answer for that but I could mainly find problems occurring after Anaconda was just installed (mine has been installed previously and was working fine up until yesterday).
I have also tried this answer and this answer but they did not solve the problem.
The only think I can think of which may have provoked this error is that I changed the interpreter used by Spyder yesterday from the default Anaconda Python interpreter to an interpreter from a virtual environment created with virtualenv. Even then, I could close and restart Spyder with no problems, and the errors started after I rebooted my computer.
[edit] I should add that both Anaconda and my virtual environment use the same version of Python which is Python 3.5
If you are using a different python version, whatever packages that you had with anaconda or that you may have installed with conda install will not be there on the new version. You need to install them with pip or conda again.