import is successful in jupyter notebook but fails with cmd - python

I installed torch using pip, and it went successfully! When I import it in jupyter notebook it is successfull. But when I try to use it cmd, it fails! any help?
Below is what shows on my cmd
C:\Users\my_pc_name>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'

Related

Ubuntu python Qt import fail

I am not able to launch git-cola on Ubuntu 20.04. As a troubleshooting exercise, I did this:
darnstein#EXTP346360104:Downloads$ python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtWidgets import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/python3/dist-packages/PyQt5/QtWidgets.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTI13QOpenGLWidget, version Qt_5
What should I do to resolve the undefined symbol?
I have packages python3-qt5 python3-pyqt5 installed already.

Python module not found after installation

I'm trying to install the python module netcdf4. I seem to have been able to do this successfully, but then I get the "module not found error" when I try to import it in python. Having looked at some similar questions, I suspect the issue has something to do with the path, but I don't know what do about that. Here's what happens specifically:
(base) C:\Users\jwmil>conda install netcdf4
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(base) C:\Users\jwmil>python
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import netcdf4 as pc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netcdf4'

Error importing cv2 in Python after opencv installation

I've successfully installed OpenCV, but when I try to import it in Python, I get the errors below.
In Python 2.7, I'm getting this
[imukunya#li165-244 site-packages]$ python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
In Python 3.6, I'm getting this error
[imukunya#li165-244 site-packages]$ python3.6
Python 3.6.5 (default, Apr 10 2018, 17:08:37)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_cv2)
I've already tried installing NumPy using $~python3 -m pip install numpy -I
Please try to execute the below command. Then please verify whether your code is working.
python -m pip install opencv-contrib-python

How to fix ImportError in PyQt5?

I install new version of Anaconda (Python 3.6) and now I can not import PyQt.
I reinstalled it three times and add <>\Anaconda3.6\Lib\site-packages\PyQt5\Qt\bin to PATH variable. But it did not help.
$ python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: Could not find the specified module
Try to add file python3.dll from python.org to your anaconda's directory.
In my case i had there only python36.dll

DLL load failed : in installing opencv2?

Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
I am trying to install open cv on python but this message shows up.
should I download opencv of 32 bit is this the case?
The problem is with incompatible lib.numpy is (mostly) compatible with 32bit.
So install
Python (32bit)
Numpy
OpenCV(32 bit)
Python 2.7 is only compatible with OpenCV2
Doesn't matter if you have a 64bit machine, 32-bit software can be run on a 64-bit Operating System.
I used pip install opencv-python it worked for me https://pypi.python.org/pypi/opencv-python

Categories

Resources