Cannot import mxnet package in my environment - python

I want to install mxnet with gpu. and used pip install mxnet-cu90. However, when I am importing the package I come across this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\__init__.py", line 24, in <module>
from .context import Context, current_context, cpu, gpu, cpu_pinned
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\context.py", line 24, in <module>
from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\base.py", line 213, in <module>
_LIB = _load_lib()
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\base.py", line 204, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File "C:\Users\Anuj\anaconda3\envs\py36\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I tried reinstalling by downloading .whl file from this but it didn't work. Its still giving the same error.
I am using python 3.6.12.

I still don't know what was causing this problem but I solved by installing the package from conda.
First I created a brand new environment and used
conda install -c anaconda mxnet-mkl
Hopefully it works for you too.

Related

Why does importing any library i have in python keep brining up errors?

I am trying to import 2 libraries into python, and there seems to be always an issue.
I have even tried to import other libraries to see if the issue is with the specific libraries I want to use, but I still get the same issue. I need to use Pandas and Matplotlib if that helps.
I always enter:
import pandas as pd
import matplotlib as plt
For matplotlib, i get this error:
PS C:\Users\mghaf\Documents\GitHub\Modelling-Cell-Growth-in-CFU> & C:/Users/mghaf/Anaconda3/python.exe c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py
Traceback (most recent call last):
File "c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py", line 1, in <module>
import matplotlib
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import cbook, rcsetup
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\matplotlib\cbook\__init__.py", line 28, in <module>
import numpy as np
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py", line 148, in <module>
from . import _distributor_init
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\mghaf\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
For pandas I get this error:
PS C:\Users\mghaf\Documents\GitHub\Modelling-Cell-Growth-in-CFU> & C:/Users/mghaf/Anaconda3/python.exe c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py
Traceback (most recent call last):
File "c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py", line 1, in <module>
import pandas
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\pandas\__init__.py", line 11, in <module>
__import__(dependency)
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py", line 148, in <module>
from . import _distributor_init
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\mghaf\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
I am using VS code to write my code. I am using Anaconda as the base for my libraries. However, I have also used pip install and uninstall multiple times to see if the issue was from there. To no avail, it did not work. There might be some issue with the setting up of python as I have both Anaconda and Python V 3.7.x installed.
If there is anything that I need to do in my settings or anything else then I would appreciate it someone could inform me on how to do it. Thanks in Advance!
This is an issue caused due to multiple python path. To elaborate, your expected interpreter is C:/Users/mghaf/Anaconda3/python.exe as seen from your executing command.
PS C:\Us ... in-CFU> & C:/Users/mghaf/Anaconda3/python.exe c:/Us ... CC.py
Although, from the error logs, it is visible that it is using an alternate python from C:\Users\mghaf\AppData\Roaming\Python\Python38 as seen here
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\pandas\__init__.py", line 11, in <module>
I would suggest that you remove all python paths from your Windows machine apart from anything related to your Anaconda interpreter.

Error when loading scipy: OSError: [WinError 126] The specified module could not be found

I have installed scipy for python3 using pip inside of a virtualenv. When I try to import scipy, I get the following error:
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\chriz\PycharmProjects\untitled1\venv\lib\site-packages\scipy\__init__.py", line 104, in <module>
from . import _distributor_init
File "C:\Users\chriz\PycharmProjects\untitled1\venv\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2032.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I seem to be missing some sort of dependency, but I don't know what the dependency is
When I look for the .dll that it is trying to open, it appears to be there
just faced the same error. The solution is downgrade scipy:
pip install scipy==1.4.1
I found it here:
https://github.com/pytorch/ignite/issues/1153

Cannot import Pytorch

While importing installed pytorch I am facing below issue
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\torch\__init__.py", line 81, in <module>
ctypes.CDLL(dll)
File "C:\Anaconda3\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I found a possible culprit by doing a Google search. Please read below-
It's a library load issue. More details at #8836
You probably have a broken conda right now. You can use a standalone conda from here to repair it:
standalone-conda.exe update -p C:\ProgramData\Anaconda3 conda-package-handling
You should get the latest stable version, and the problems should go away.
More details can be found here.

How to fix:- libmxnet.so: cannot open shared object file: No such file or directory

I'm trying to install mxnet on Yocto (Rocko) for my 64-bit Armv8-A.
I did pip3 install mxnet and it was successfully installed. It was installed in -
/usr/lib/python3.5/site-packages
I copied mxnet and mxnet-1.6.0.dist-info to -
/usr/lib64/python3.5/site-packages
Then, i tried import mxnet and it gave me the below errors-
ERROR:
>>> import mxnet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.5/site-packages/mxnet/__init__.py", line 24, in <module>
from .context import Context, current_context, cpu, gpu, cpu_pinned
File "/usr/lib64/python3.5/site-packages/mxnet/context.py", line 24, in <module>
from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
File "/usr/lib64/python3.5/site-packages/mxnet/base.py", line 214, in <module>
_LIB = _load_lib()
File "/usr/lib64/python3.5/site-packages/mxnet/base.py", line 205, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File "/usr/lib64/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib64/python3.5/site-packages/mxnet/libmxnet.so: cannot open shared object file: No such file or directory
I checked and there is libmxnet.so in my /usr/lib64/python3.5/site-packages/mxnet/ folder.
How do i solve this issue?
mxnet on ARM must be built from source, as per this GitHub issue.
Instructions on how to do this can be found here.

Error installing firebird RDBMS bindings package on windows

I am installing the fdb package on windows
This package
https://pypi.python.org/pypi/fdb
and i get this error
C:\fdb>python setup.py install
Traceback (most recent call last):
File "setup.py", line 7, in <module>
from fdb import __version__
File "C:\fdb\fdb\__init__.py", line 23, in <module>
from fdb.fbcore import *
File "C:\fdb\fdb\fbcore.py", line 26, in <module>
from . import ibase
File "C:\fdb\fdb\ibase.py", line 43, in <module>
fb_library = WinDLL(fb_library_name)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: expected string or Unicode object, NoneType found
Has anyone encountered this error before?.I have the python driver for firebird installed and also the python driver.
I solved it. After installing the Firebird super server, copy fbclient.dll (you will find it under C:\Program Files\Firebird\Firebird_2_5\bin) and paste it under C:\WINDOWS
If your problem persists, there is a hack I found on the firebird-python mailing list on Yahoo here: Re: Again: can't install fdb

Categories