I have pip installed nflfastpy ,
But when I import it.
running only
import nflfastpy
i get this error message
(pythonCoursera) C:\Users\austi\PycharmProjects\pythonCoursera>python sportsbet.py
Traceback (most recent call last):
File "C:\Users\austi\PycharmProjects\pythonCoursera\sportsbet.py", line 2, in <module>
import nflfastpy as nfl
File "C:\Users\austi\anaconda3\envs\pythonCoursera\lib\site-packages\nflfastpy\__init__.py", line 16, in <module>
default_headshot = mpl_image.imread(headshot_url)
File "C:\Users\austi\anaconda3\envs\pythonCoursera\lib\site-packages\matplotlib\image.py", line 1536, in imread
raise ValueError(
ValueError: Please open the URL for reading and pass the result to Pillow, e.g. with ``np.array(PIL.Image.open(urllib.request.urlopen(url)))``.
on 1 single line of code, nothing else in the file,
I've trie a few versions of it, cant seem to figure it out.
Any suggestions?
That library has a bug and seems to be not actively maintained. You are on your own. At least that image loading error can be avoided by removing the dead code in nflfastpy/__init__.py like the following.
...
#default_headshot = mpl_image.imread(headshot_url)
Related
I'm trying to import the NERDA library in order use it to engage in a Named-Entity Recognition task in Python. I initially tried importing the library in a jupyter notebook and got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\NERDA\models.py", line 13, in <module>
from .networks import NERDANetwork
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\NERDA\networks.py", line 4, in <module>
from transformers import AutoConfig
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\__init__.py", line 43, in <module>
from . import dependency_versions_check
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\dependency_versions_check.py", line 36, in <module>
from .file_utils import is_tokenizers_available
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\file_utils.py", line 51, in <module>
from huggingface_hub import HfApi, HfFolder, Repository
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\huggingface_hub\__init__.py", line 31, in <module>
from .file_download import cached_download, hf_hub_url
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\huggingface_hub\file_download.py", line 37, in <module>
if tuple(int(i) for i in _PY_VERSION.split(".")) < (3, 8, 0):
File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\huggingface_hub\file_download.py", line 37, in <genexpr>
if tuple(int(i) for i in _PY_VERSION.split(".")) < (3, 8, 0):
ValueError: invalid literal for int() with base 10: '6rc1'
I then tried globally installing using pip in gitbash and got the same error. The library appeared to install without error but when I try the following import, I get that same ValueError:
from NERDA.models import NERDA
I've also tried some of the pre-cooked model imports and gotten the same ValueError.
from NERDA.precooked import EN_ELECTRA_EN
from NERDA.precooked import EN_BERT_ML
I can't find anything on this error online and am hoping someone may be able to lend some insight? Thanks so much!
Take a look at the source code of the used huggingface_hub lib. They comparing the version of your python version to do different imports.
But you uses a release candidate python version (this tells the value '6rc1', that caused the error). Because they didn't expect/handle this, you get the int-parse-ValueError.
Solution 1:
Update your python version to a stable version. No release candidate. So you have an int-only version number.
Solution 2:
Monkeypatch sys.version, before you import the NERDA libs.
sys.version = '3.8.0'
I am a complete novice at Python and I wish to run a script someone has made up to check against a critical windows vulnerability. I downloaded python and I thought I had downloaded all the modules and everything needed to run this script, but I keep getting an error: Please see below
C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages>zerologon.py Dc_Name IP_address ( I put this here but I edited it for confidentiality)
Traceback (most recent call last):
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\zerologon.py", line 3, in <module>
from impacket.dcerpc.v5 import nrpc, epm
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\nrpc.py", line 30, in <module>
from impacket.dcerpc.v5.samr import OLD_LARGE_INTEGER
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\samr.py", line 29, in <module>
from impacket.dcerpc.v5.rpcrt import DCERPCException
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\rpcrt.py", line 24, in <module>
from Cryptodome.Cipher import ARC4
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\__init__.py", line 27, in <module>
from Cryptodome.Cipher._mode_ecb import _create_ecb_cipher
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\_mode_ecb.py", line 35, in <module>
raw_ecb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ecb", """
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\_raw_api.py", line 308, in load_pycryptodome_raw_lib
raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
OSError: Cannot load native module 'Cryptodome.Cipher._raw_ecb': Trying '_raw_ecb.cp38-win_amd64.pyd': cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.cp38-win_amd64.pyd': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.cp38-win_amd64.pyd', Trying '_raw_ecb.pyd': cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.pyd': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.pyd'
Here is a link to the github script: https://github.com/SecuraBV/CVE-2020-1472 , let me know if anyone can assist because I have no clue what I'm doing wrong
Since you said you're a novice at Python, I'll try to help you.. but you should definetely take a look at the links provided in the first comment.
So, after the formalities, let's read your error message together..
C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages>zerologon.py Dc_Name IP_address
the error was caused by this command: zerologon.py Dc_Name IP_address
Traceback (most recent call last):
traceback will show the error at the top and their dependencies...
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\zerologon.py", line 3, in <module>
from impacket.dcerpc.v5 import nrpc, epm
the first line is located in your script, the zerologon.py, at line 3, where you try to run the following command: from impacket.dcerpc.v5 import nrpc, epm
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\nrpc.py", line 30, in <module>
from impacket.dcerpc.v5.samr import OLD_LARGE_INTEGER
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\samr.py", line 29, in <module>
from impacket.dcerpc.v5.rpcrt import DCERPCException
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\rpcrt.py", line 24, in <module>
from Cryptodome.Cipher import ARC4
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\__init__.py", line 27, in <module>
from Cryptodome.Cipher._mode_ecb import _create_ecb_cipher
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\_mode_ecb.py", line 35, in <module>
raw_ecb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ecb", "")
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\_raw_api.py", line 308, in load_pycryptodome_raw_lib
raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
and here, in the last "File Error Message", we can see the root of your problem: the file \Python\Python38-32\Lib\site-packages\Cryptodome\Util\_raw_api.py, in line 308, tried to run the command: load_pycryptodome_raw_lib, but it generated an OSError...
OSError: Cannot load native module 'Cryptodome.Cipher._raw_ecb':
here we can see the OSError message: Cannot load native module 'Cryptodome.Cipher._raw_ecb', and the following part shows us the unsuccessful alternative attempts..
Trying '_raw_ecb.cp38-win_amd64.pyd':
cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.cp38-win_amd64.pyd': error 0x7e.
Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.cp38-win_amd64.pyd',
Trying '_raw_ecb.pyd': cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.pyd': error 0x7e.
Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.pyd'
Ok, so after executing this reading and understanding routine, we can try to find a solution to your problem, by looking at:
Cryptodome Docs
Cryptodome Github Issues
After doing this, you can even specify your search using the raw_ecb text, for example... which leads us to this page, that may be very useful for you:
ISSUES filtered by "_raw_ecb.pyd"
Or this one:
Error loading native modules #185
In this issue, the OP said the following:
"I solved it by installing the VC++ 2008 Redistributable as I could see
in dependencywalker that MSVCR90 was not found"
I know this doesn't clearly answer your question, but it may help you understand how you can fix your code in a more general way..
>>> import face_recognition
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/username/Desktop/face_recognition_low/face_recognition.py", line 30, in <module>
np.set_printoptions(threshold=np.nan)
File "/Users/username/.virtualenvs/cv/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 246, in set_printoptions
floatmode, legacy)
File "/Users/username/.virtualenvs/cv/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 93, in _make_options_dict
raise ValueError("threshold must be numeric and non-NAN, try "
ValueError: threshold must be numeric and non-NAN, try sys.maxsize for untruncated representation
There was no problem importing face_recognition yesterday but all of sudden it does not work. I have no idea how to fix this problem... Any assistance would be highly appreciated.
I restarted my mac and tried again now it works fine. I would like to figure out why...
>>> import dlib
>>> import face_recognition
>>>
Please import sys by import sys.
Then replace
np.set_printoptions(threshold=np.nan)
with
np.set_printoptions(threshold=sys.maxsize)
I've followed the instructions in Detectron and I've configured it several times: the code compiles as it should. When it comes to run the code, I get this error:
Traceback (most recent call last):
File "tools/train_net_step.py", line 21, in <module>
import nn as mynn
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/__init__.py", line 2, in <module>
from .parallel import DataParallel
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/parallel/__init__.py", line 3, in <module>
from .data_parallel import DataParallel, data_parallel
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/parallel/data_parallel.py", line 4, in <module>
from .scatter_gather import scatter_kwargs, gather
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/nn/parallel/scatter_gather.py", line 8, in <module>
from torch.utils.data.dataloader import numpy_type_map
ImportError: cannot import name 'numpy_type_map'
I've also tried to google it many times, but I can't find a way to solve it. What can I do? I'm using PyTorch 0.4.1 and pytorch nightly 1.0.0-dev.
EDIT: Thanks to sancelot, I managed to solve that error (PyTorch 0.4.0 did the thing). Anyway, now I've got another error:
Traceback (most recent call last):
File "tools/train_net_step.py", line 27, in <module>
from modeling.model_builder import Generalized_RCNN
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/modeling/model_builder.py", line 11, in <module>
from model.roi_pooling.functions.roi_pool import RoIPoolFunction
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/model/roi_pooling/functions/roi_pool.py", line 3, in <module>
from .._ext import roi_pooling
File "/home/federico/PycharmProjects/Detectron.pytorch/lib/model/roi_pooling/_ext/roi_pooling/__init__.py", line 3, in <module>
from ._roi_pooling import lib as _lib, ffi as _ffi
ImportError: /home/federico/PycharmProjects/Detectron.pytorch/lib/model/roi_pooling/_ext/roi_pooling/_roi_pooling.so: undefined symbol: PyInt_FromLong
What I can't get this time is: is this an error given by an external library? I'm using an anaconda environment previously made by my professor, who has used it for Detectron... so I can't guess why I get this.
Yeah, these are due to Pytorch version mismatch. Solution depends on what extent you are willing to go, sometimes if you are okay with hacking and just getting it running, then just copy paste the numpy_type_map from older versions:
numpy_type_map = {
'float64': torch.DoubleTensor,
'float32': torch.FloatTensor,
'float16': torch.HalfTensor,
'int64': torch.LongTensor,
'int32': torch.IntTensor,
'int16': torch.ShortTensor,
'int8': torch.CharTensor,
'uint8': torch.ByteTensor,
}
Or, up to version 1.1.0, you can try replacing the import statement,
from:
from torch.utils.data.dataloader import numpy_type_map
to:
from torch.utils.data._utils.collate import numpy_type_map
N.b. will still break in more recent versions. Again, this is a hacky quick-fix solution.
I suppose there is a version mismatch between detectron and the needed pytorch release you are using.
if you look at latest pytorch source code, there is no numpy_type_map component.
https://github.com/pytorch/pytorch/blob/master/torch/utils/data/dataloader.py
I am trying to import theano in a module, but I am getting a traceback:
File "/media/tarun/6A86CA8286CA4DEF/develop/pydy/pydy/codegen/code.py", line 16, in <module>
import theano
File "/usr/local/lib/python2.7/dist-packages/theano/__init__.py", line 44, in <module>
from theano.gof import \
File "/usr/local/lib/python2.7/dist-packages/theano/gof/__init__.py", line 38, in <module>
from theano.gof.cc import \
File "/usr/local/lib/python2.7/dist-packages/theano/gof/cc.py", line 55, in <module>
StrParam(""))
File "/usr/local/lib/python2.7/dist-packages/theano/configparser.py", line 223, in AddConfigVar
root=newroot, in_c_key=in_c_key)
File "/usr/local/lib/python2.7/dist-packages/theano/configparser.py", line 227, in AddConfigVar
configparam.fullname)
AttributeError: ('This name is already taken', 'gcc.cxxflags')
It seems that there is some name conflict in some config. Can anybody please point me to the same.
This error happens because some module, probably theano.gof, is imported twice. Usually, this is because a first call to import theano.gof gets started, registering 'gcc.cxxflags' in the configuration parser a first time, but then raises ImportError, which is catched and ignored.
Then, import theano.gof gets called again, tries to register the option again, which raises the exception you get.
Is there any traceback or error message before this one, or something that would give a hint of why the first import failed?
I got similar error using when using the jupyter notebook. Restarting kernel solved the issue.