Installed pytorch on M1 MacBook, but can't import torch - apple-m1

I did install pytorch on my M1 MacBook. But if I try to import it, I keep getting an error saying No module named 'torch'
Here's several ways I tried:
(method #1 and #2 are from Pytorch official website)
#1
conda install pytorch torchvision torchaudio -c pytorch
#2
conda install pytorch torchvision torchaudio -c pytorch-nightly
#3
this medium article
And If I try to run those command again, it say it's already installed, but if i run import torch, it say No module named 'torch' in Jupyter noteboook.
And in terminal if I type python then import torch works but if if type python3 then import torch does not work.
Why I'm getting this error, and how can fix this issue?

Related

libgssapi_krb5.so.2: undefined symbol: k5_sname_compare in while importing PyQt6.QtWebEngineWidgets [duplicate]

After installing anaconda3, I began to install pyside2.
I directly typed pip install pyside2, and successfully installed pyside2 5.15. But when I ran the toy example, an error occurred:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from PySide2.QtWidgets import QApplication, QLabel
ImportError: /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2: symbol krb5_ser_context_init version krb5_3_MIT not defined in file libkrb5.so.3 with link time reference
I when to /usr/lib/x86_64-linux-gnu and found both libgssapi_krb5.so.2 and libkrb5.so.3, and I have no idea how to fix this bug. Can anybody help me?
My environment:
python: 3.8.3
OS: ubuntu 18.04
CPU: AMD ryzen 3600
You are getting the error because you have a wrong version of qt on your machine. I mean it seems anaconda installs the wrong version of QT by default. First, you need to install essential packages (enter link description here) and then do the following steps:
pip uninstall pyside2, qt, pyqt5 if you have installed them with pip
conda remove pyside2, qt, pyqt5 if you have installed them with conda
conda install -c conda-forge pyside2
I had a similar issue, though I was not using anaconda. The error appears to be a krb5 version mismatch between PySide2 and Ubuntu packages. I was able to resolve the issue by compiling krb5 from source and adding the lib directory to LD_LIBRARY_PATH.
tar xf krb5-1.18.2.tar.gz
cd krb5-1.18.2/src
./configure --prefix=/opt/krb5/
make && make install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/krb5/lib
python -c "import PySide2.QtCore"
The python import no longer raised an error. I found this worked with several different krb5 versions from the offical website; the error seems to be in the Ubuntu modifcations to the package.
You may have success with uninstalling and reinstalling the Python Qt bindings, as suggested by the other answers, but this did not work for me.
Just build in the pyside2 dependencies. if you wanna to use your virtual environment.
End build the Clang Library
I am sorry, your answer above seems correct except for the presence of opencv, which is not in the original question. Opencv in my opinion has nothing to do with pyside2 or the question. So, the correct procedure in my opinion would be:
1. pip uninstall pyside2, qt, pyqt5 if you have installed them with pip
2. conda remove pyside2, qt, pyqt5 if you have installed them with conda
3. conda install -c conda-forge pyside2

some modules could not be import on jupyter notebook after installed from miniforge

I got some error like ModuleNotFoundError: No module named 'numpy' on apple silicon MacBook Pro. Since some modules can not install on MacBook by pip, then I used miniforge and conda successfully to install numpy, mathplot and pandas. However, those modules could be imported on jupyter notebook.
Any suggestions for solving this?

How to enable Stata kernel in jupyter notebook

I am using MacOS and try to use Stata in the jupyter notebook. I went over the following step to do so.
First, in the terminal:
pip install stata_kernel
python -m stata_kernel.install
conda install -c conda-forge nodejs -y
jupyter labextension install jupyterlab-stata-highlight
pip install ipystata
And then in my jupyter notebook:
import ipystata
from ipystata.config import config_stata
config_stata('/Macintosh HD⁩/Applications/Stata/StataSE')
import ipystata
%%stata
display "Hello, I am printed in Stata."
But I keep getting the error message
UsageError: Line magic function %%stata not found.
I am not sure if this is path problem or something else.
Could you help me to fix the problem?

How to fix Google colab import errors on statsmodels logsumexp and factorial

Am getting import errors in google collab Jupyter notebook on statsmodels packages such as logsumexp and factorial.
Please suggest.
from scipy.misc import logsumexp
from scipy.misc import factorial
ImportError: cannot import name 'logsumexp'
ImportError: cannot import name 'factorial'
I have re-installed the scipy and sci-kit and restarted runtime of google collab jupyter notebook. However, import still persists.
Was looking for a similar problem in colabs and did the below:
! pip install --upgrade Cython
! pip install --upgrade git+https://github.com/statsmodels/statsmodels
import statsmodels.api as sm
Got it from the below link: This issue is solved temporarily
I'm working on google colab. then i got same problem "can not import name :factorial".Actually it comes from scipy .
For windows
pip3 install --user scipy==1.2.0
For Linux
python3.6 -m pip install scipy==1.2 --upgrade
change
from scipy.misc import factorial
to
from scipy.special import factorial
in a couple of places (everywhere, where you get an error message)
same with
comb, logsumexp

Jupyter: jupyter-notebook can not import module statsmodels

I have installed jupyter notebook in MacOS 10.9 Mavericks, using command
pip3 install jupyter
I can import some libraries like numpy, pandas and run Jupiter notebook normally, however, if I import the module statsmodels, it says No Module named "statsmodels'.
How can we run the installed library statsmodels in jupyter-notebook?
I had the same problem.
That's because the module has been install for python2 and not for python3 that you are using as well.
Find your python3 bin related to jupyter.
$jupyter --paths
Mine was at /usr/local/Cellar/python3/3.5.2_3/bin
run :
$python3 -mpip install statsmodels
cheers

Resources