Cannot import MetaTrader5 - python

While importing MetaTrader5 :
import MetaTrader5 as mt
I got the following error :
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xe
Traceback (most recent call last):
File ~\OneDrive\Documents\Programmation\Projets\TRAI\utilities_mt5.py:10
import MetaTrader5 as mt
File ~\anaconda3\lib\site-packages\MetaTrader5\__init__.py:257
from ._core import *
ImportError: numpy.core.multiarray failed to import
I've search a lot and found nothing, so I'm asking, hoping for some answers.
I'm using Spyder, Python 3.8

Try updating your numpy
pip install -U numpy

Related

Although numpy is installed I get an "ModuleNotFoundError" if I try to use it

If i run pip install numpy then I get
Requirement already satisfied: numpy in /Users/aaditya/.pyenv/versions/3.8.5/lib/python3.8/site-packages (1.19.5)
But if I use import numpy as np in a python file then I get
Traceback (most recent call last):
File "/Users/aaditya/Desktop/Blender_software/Blender_algo_exp/quantity_sol.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Although if I run import numpy as np in my terminal directly then it works. Is there any way to fix this?
I think you just need restart Visual Code or Pycharm
Or you should check python IDE for Visual Studio
Another solution is run command
python3 -m pip install numpy

Import Error: Problem with importing from Python Package

import audiolabel
import numpy as np
from ultramisc import ebutils as eb
from audiolabel import LabelManager
ImportError Traceback (most recent call last)
<ipython-input-38-2387500242d1> in <module>
4
5 from ultramisc import ebutils as eb
----> 6 from audiolabel import LabelManager
ImportError: cannot import name 'LabelManager' from 'audiolabel' (unknown location)
In [39]:
I'm trying to import LabelManager from the audiolabel package I got using git clone but for some reason there is no way to import LabelManager? I'm not sure why this is the case, because from all the documentation I've seen from audiolabel, they are able to import LabelManager
This error could be caused by multiple reasons...
Have you tried downloading via pip install ?
pip3 install "git+https://github.com/rsprouse/audiolabel.git"

How to resolve error importing stats.scipy.loguniform

When importing 'loguniform' from scipy.stats i get an importerror.
Both in colab.google and jupyter.
I am running python 3.7.
scipy version 1.3.0
I even just upgraded to version 1.4.1, still the same error.
code:
from scipy.stats import loguniform
error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-b01b9ec1c262> in <module>
----> 1 from scipy.stats import loguniform
ImportError: cannot import name 'loguniform' from 'scipy.stats'
other distributions load just fine,
from scipy.stats import uniform
no problem.
For Python 3 SciPy version 1.4.0 or higher should allow you to install loguniform.
So, type import scipy, then type print(scipy.__version__) and make sure 1.4.0 or newer is installed, then type from loguniform import scripy.stats.
You have the import backwards. You are importing scipy.stats from the library loguniform.
Try:
from loguniform import scripy.stats
You can reference the Library description for more details on the uses of the library Here

Why I cannot import 'make_vec_env' from stable baselines?

I have some problems with the example of stable-baselines and look forward to your help.
The environment is set as:
Windows 10
spyder 3.6
tensorflow 1.4.0
gym 0.15.4
stable_baselines 2.8.0
However, I cannot import:
from stable_baselines.common import make_vec_env
The error is:
Traceback (most recent call last):
File "<ipython-input-96-9dcb30379014>", line 1, in <module>
from stable_baselines.common import make_vec_env
ImportError: cannot import name 'make_vec_env'
If this is the module we are talking about.
https://github.com/hill-a/stable-baselines
Seems like there was an issue that has been solved in 2.9.0:
https://github.com/araffin/rl-baselines-zoo/issues/51
Upgrade your stable-baselines:
pip install stable-baselines==2.9.0
And then it should be enough to use:
from stable_baselines.common.cmd_util import make_vec_env

Numpy and OpenCV

I'm tired to import cv and numpy and get errors. I started importing cv and I got this error:
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "", line 1, in <module>
File "/usr/lib/pymodules/python2.7/cv.py", line 1, in <module>
from cv2.cv import *
ImportError: numpy.core.multiarray failed to import
So I installed numpy on Ubuntu using:
apt-get install python-numpy
So when I import numpy I get:
Traceback (most recent call last):
File "", line 1, in <module>
File "numpy/init.py", line 127, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
I really need help. I'm using Python 2.7.3 on Ubuntu.
There is nothing wrong with installing common dependencies using your operating system's package manager, remember using pip means your synaptic updates won't update your Python libraries and pip won't leverage the dependencies already taken care of by aptitude. For python packages with C extensions like numpy and opencv its probably better to use apt-get.
In Ubuntu you can install both dependencies with
sudo apt-get install python-numpy python-opencv
The actual Python error you are getting indicates what is wrong, namely that you are executing from within the numpy source directory, or have a file named numpy.py in your current directory which is confusing things at import time. Try change into an empty directory, start Python import your libraries:
import numpy
import cv
Hope that helps.
It's better that use some package management tool such like pip to install numpy.
For example,
pip install numpy

Categories