I have already install the gmane, for sure i have run the upgrade.
pip install gmane --upgrade
And then it show me those:
'Requirement already up-to-date: gmane in ./lib/python2.7/site-packages'
>>> import gmane
It's shows me these errors:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/code/site/local/lib/python2.7/site-packages/gmane/__init__.py", line 26, in <module>
from .networkEvolution import NetworkEvolution
File "/root/code/site/local/lib/python2.7/site-packages/gmane/networkEvolution.py", line 9, in <module>
from .pca import *
File "/root/code/site/local/lib/python2.7/site-packages/gmane/pca.py", line 79
def __init__(self,*metrics,final_dimensions=2,draw=False):
^
SyntaxError: invalid syntax
Anyone help?
I have review the error, found the error 'syntax error'.So i have write a very simple sample to confirm it.
class MyGmane:
def __init__(self,*meteris ,final_dimensions=2,draw=False):
pass
if __name__ == '__main__':
mg = MyGmane()
I got the following error:
python $python q.py
File "q.py", line 2
def __init__(self,*meteris ,final_dimensions=2,draw=False):
^
SyntaxError: invalid syntax
After i change the order inside the init method like below:
def __init__(self,final_dimensions=2,draw=False,*meteris):
And then it work,so I have modify this file (line 79)
"/root/code/site/local/lib/python2.7/site-packages/gmane/pca.py"
It's also work, so i guess there are maybe have a bug on 'game'!
Related
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)
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 have a script using openpyxl to add rows to an existing xlsx spreadsheet. It was running fine a couple of weeks ago: however, when I run it now, it starts to give me different syntax error in Python2 and Python3.
The problem I have is that the syntax error is pointing to the import packages rather than somewhere in code.
Any suggestion on how to fix these syntax issues?
Error with Python2
IDA-Data host$ python2 add_name_excel_dirs.py
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 62, in <module>
import os
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 400, in <module>
import UserDict
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 116, in <module>
import _abcoll
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py", line 662
def append(self, value: object) -> object:
^
SyntaxError: invalid syntax
Error with Python3 when running the same script:
IDA-Data host$ python3 add_name_excel_dirs.py
Traceback (most recent call last):
File "add_name_excel_dirs.py", line 5, in <module>
from openpyxl import load_workbook
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/__init__.py", line 26, in <module>
from openpyxl.compat.numbers import NUMPY, PANDAS
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/compat/__init__.py", line 5, in <module>
from .strings import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/compat/strings.py", line 9, in <module>
from .numbers import NUMERIC_TYPES
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/compat/numbers.py", line 28, in <module>
import pandas
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/__init__.py", line 58, in <module>
from pandas.io.api import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/api.py", line 10, in <module>
from pandas.io.pytables import HDFStore, get_store, read_hdf
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/pytables.py", line 918
def append(self, key: object, value: object, format: object = None, append: object = True, columns: object = None,
^
SyntaxError: non-default argument follows default argument
I'm learning to use tqdm. I made a very simple test case but met with NameError. The test case is as follows:
from tqdm import tqdm_notebook
num = 100
bar = tqdm_notebook(total=num)
The file name is b.py and I run:
python b.py
The error happened and the error message is:
Traceback (most recent call last):
File "b.py", line 4, in <module>
bar = tqdm_notebook(total=num)
File "/usr/local/lib/python2.7/dist-packages/tqdm/__init__.py", line 19, in tqdm_notebook
return _tqdm_notebook(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tqdm/_tqdm_notebook.py", line 183, in __init__
self.sp = self.status_printer(self.fp, self.total, self.desc)
File "/usr/local/lib/python2.7/dist-packages/tqdm/_tqdm_notebook.py", line 104, in status_printer
ptext = HTML()
NameError: global name 'HTML' is not defined
I thought it was because I did not install a package named HTML, so that I run
sudo pip install HTML
It did installed an HTML package. But the error remained the same when I run the test case again.
What's wrong with this example? Did I miss other packages? Thank you all for helping me!
I've installed Python 2.7.2 on my Windows XP computer.
I recently installed SQLAlchemy 0.7.1 using 'python setup.py install'. During the installation, I got the following error messages:
byte-compiling C:\Python27\Lib\site-packages\sqlalchemy\sql\visitors.py to visitors.pyc
SyntaxError: ('invalid syntax', ('C:\\Python27\\Lib\\site-packages\\sqlalchemy\\sql\\visitors.py', 66, 34, 'class Visitable(object, metaclass=VisitableType):\n'))
When I try to import sqlalchemy, I get the following stack trace:
>>> import sqlalchemy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\expression.py", line 32, in <module>
from sqlalchemy import util, exc
File "C:\Python27\lib\site-packages\sqlalchemy\util\__init__.py", line 7, in <module>
from .compat import callable, cmp, reduce, defaultdict, py25_dict, \
File "C:\Python27\lib\site-packages\sqlalchemy\util\compat.py", line 93, in <module>
callable = __builtin__.callable
NameError: name '__builtin__' is not defined
Other scripts work fine and all the functions in __builtin__ seem to be available.
I can't find any examples of similar problems on Google or in the SQLAlchemy documentation.
What's wrong?
UPDATE:
Uncommenting import __builtin__ in compat.py removed the first problem. Now I seem to have problems with visitors.py:
>>> import sqlalchemy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\expression.py", line 35, in <module>
from sqlalchemy.sql.visitors import Visitable, cloned_traverse
File "C:\Python27\lib\site-packages\sqlalchemy\sql\visitors.py", line 66
class Visitable(object, metaclass=VisitableType):
^
SyntaxError: invalid syntax
Problem partially solved: everything started working when I rolled back to SQLAlchemy 0.6.8. An issue with 0.7.1 + Windows/2.6?