"No module named specutils" although specutils installation went through - python

I am trying to install the Specutils package.
I followed these instructions and typed the following command in my Anaconda Prompt terminal:
conda install -c astropy specutils
The installation went through. Typing conda list confirms that specutils 0.5.2 is installed.
However, trying to import specutils from Spyder does not work! I am getting a message stating that there is No module named specutils.
Any clue what I am doing wrong?
FYI, I am working from the "base" conda environment.

These problems are in most instances problems with the IDE. It does not pick up on the right Python environment that you installed stuff into. Verify this by running python from the command line and note the output of import sys;print(sys.prefix). Compare that to the one you are getting from within Spyder.

Related

Why doesn't import gym work; however, the command pip install gym was done and executed

I have went to the terminal and used,"pip install gym", and it successfully installed gym . When I go to use the, "import gym," command, I get an error when running the code at that line.
Exception has occurred: ModuleNotFoundError
No module named 'gym'
I have looked at other posts and they all say it should work after ruining,"pip install gym." Although mine successfully installed, it still doesn't work.
You need to verify that you are using the same version of python that you did pip install with. In VS Code, you can select the Python version in the upper right corner. Simply type "python --version" into the console to verify the version. You might want to use Anaconda because someone libraries like Tensorflow only fully-support Anaconda.
if you have pip installed it, there is no way that it will not work. Unless you've installed it to a virtual environment and running your program without it and vice versa. Or you've installed to a different version of python on your system.

FreeCAD import error while using Spyder "ImportError: DLL load failed while importing FreeCAD: The specified procedure could not be found."

My FreeCAD software runs on Windows 10. Its built-in Python console uses Python 3.8. In order to import its modules to an external Python, I created a Python3.8 environment in anaconda and the module can be successfully imported with Jupyter QtConsole. However, import errors show up when I do the same thing in Spyder. Does anyone have a similar problem? Any idea what is going on here? (see the images below)
successful import in Jupyter QtConsole
Failed import in Spyder
I uninstall the Freecad program and use ananconda to reinstall the Freecad package. Now the Spyder works fine.
FYI: Use the following command (I copied from the wiki page) to do the installation: "conda create --name fcenv --channel conda-forge freecad"
Creating a new environment seems to be necessary. Otherwise, the installation will fail.

Python Can't Find Module After Installing with Pip and Conda

I am on Windows Subsystem for Linux (WSL). I've defined an environment and I am trying to add the palettable package to it. This is what I tried:
conda install palettable, went fine no errors, tried to do import palettable in my script and I get the error ModuleNotFoundError: No module named 'palettable'
Next I did conda remove palettable
Then I installed again, this time using pip by doing pip install palettable
I get the same error
Did I miss a step? Or do something wrong?
I've added many other packages to this same environment using conda and not had any problems or encountered this error before.
You can easily fix this problem by restarting the kernel or IDE in which you are writing the code after installing the module..
I found the problem. I am using VSCode and I didn't realize the python interpreter and the notebook kernel are set independently. The interpreter correctly reflected that I was using my project environment. But the notebook kernel (top right corner of NB window) was not set to the same thing. Once I set it correctly and restarted the IDE it now is correctly finding the packages.

ModuleNotFoundError: No module named 'mlxtend' despite mlxtend being in pip list

I am using Python 3.8.6, with mlxtend version 0.17.3, doing this on jupyter notebook
I have installed mlxtend in my virtual environment on command prompt with
pip install mlxtend
and it also shows up on my pip list.
However when I am trying to import the module within VS Code, and selecting my venv as my python interpreter:
from mlxtend.feature_selection import SequentialFeatureSelector as SFS
I am facing the error:
ModuleNotFoundError: No module named 'mlxtend'
Appreciate any help.
Try pip list or import mlxtend in the console displaying error message. If it wasn't present there, it was an environment configuration problem. Then you can just install the module there using pip.
I remember one of my friends having same problem with some other module. He was also using some kind virtual environment, which I guess caused the problem.
The error is because of environment, and I had a similar problem, but I solved it by adding the isntalled library, in the Interpreter settings, but I did this in PyCharm, look for similar options in VS Code.
P.S. I will update if I found the option in VS.

Cannot import torch module

I cannot seem to properly install pytorch on my computer, so here is the background of what I have done:
I had already installed python on my computer and it worked. I used it in Eclipse, using pyDev, so I don't know if that could be the problem. Now I want to install pytorch, so I installed anaconda and entered the command for installing pytorch. To get the right command, I use https://pytorch.org/get-started/locally/, where I tried the options both with and without cuda. In both cases I get an error when I type "import torch".
I have also installed miniconda and tried the same with that without succes. I also tried to work in IDLE in stead of Eclipse, but I keep getting the "no module named 'torch'" error. Each time I run a command in anaconda it appears that the installation is succesfull, but I still can't import 'torch'.
Any idea what the problem could be or what I could try?
Open command prompt or terminal and type:
pip3 install pytorch
If it says pip isn't installed then type: python -m pip install -U pip
Then retry importing Pytorch module
Using anaconda, I think you can check to see if pytorch is properly installed inside your conda environment using conda list inside your environment. If it is shown in the list of installed packages, you can directly try to run python in command line and import torch as in the official Pytorch tutorial:
import pytorch
torch.cuda.is_available()
For IDEs like Eclipse, you need to edit the settings of your project so that it uses the correct conda environment.
Try to create conda-env and reinstall pytorch on conda-env.
Then try to import torch again.
import torch
torch.cuda.is_available()

Categories

Resources