What is this message when installing Pybrain - python

I checked out the latest version of Pybrain from github
Running sudo python setup.py install on my mac gives me:
Extracting PyBrain-0.3.1-py2.7.egg to /Library/Python/2.7/site-packages
File "/Library/Python/2.7/site-packages/PyBrain-0.3.1-py2.7.egg/build/lib/build/lib/pybrain/optimization/distributionbased/fem.py", line 235
updateSize = self._computeUpdateSize(self._computeDensities(sample), k)
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/PyBrain-0.3.1-py2.7.egg/build/lib/pybrain/optimization/distributionbased/fem.py", line 235
updateSize = self._computeUpdateSize(self._computeDensities(sample), k)
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/optimization/distributionbased/fem.py", line 235
updateSize = self._computeUpdateSize(self._computeDensities(sample), k)
^
SyntaxError: invalid syntax
What is this; should I worry about it?

The problem is in line 233, which is:
print(len(self.allsamples), min(self.fitnesses), max(self.fitnesses)#, self.alphas)
it comments out the self.alphas part, but it is also commenting out the closing parenthesis of the print function, so the error occurs.
I'll submit a pull request, meanwhile, you can fix it yourself by fixing the parenthesis.

It is a syntax error so you should at least raise a ticket on it and possibly resolve it and submit a patch. It looks like fem at least will not work but the error may be on line 234 as there is nothing obviously wrong with the reported line.

Related

How can I debug this Python syntax error with f string

def write_users_group(heading_writer, heading, user_writer, users):
heading_writer.writerow([f"{heading}", f"{len(users)} users"])
user_writer.writeheader()
for user in users:
user_writer.writerow(user)
heading_writer.writerow([" "])
Error:
File "/Users/ashirwadniv/Downloads/gitlab/users.py", line 59
heading_writer.writerow([f"{heading}", f"{len(users)} users"])
^
SyntaxError: invalid syntax
This syntax is only allowed for Python version 3.6 and above. Check/Upgrade your Python version.
Fyi, there is nothing wrong with your syntax provided the python version supports it.

I got "TabError" and tried 8 methods I thought would work. But still can't work it out

Edit1: I got the KNN module by using the command pip install KNN and the command worked normally, showing the module was installed. When I use the command again, it returns this:
Requirement already satisfied: KNN in c:\users\Username\appdata\local\programs\python\python310\lib\site-packages (1.0.0)
Code:
import KNN
print(KNN.__version__)
Problem: TabError: inconsistent use of tabs and spaces in indentation
Editor: VS code
OS: Windows 10
What I tried and got:
delete all tabs and spaces in the code, make sure there’s no tabs and spaces in my code.
Use ‘convert indentation to tabs’ function in VS Code editor.
Use ‘Convert indentation to spaces’ function in VS Code
Use ‘delete indentation from content’ function in VS Code
Each of these methods gets the same error:
Traceback (most recent call last): File "c:\Users\Username\Documents\python\test3", line 1, in <module> import KNN File "C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\KNN.py", line 24 print(sortedDistIndicies[i]) TabError: inconsistent use of tabs and spaces in indentation
Search for ‘Space’
Get: there’s no spaces used for indentation. And still the same error.
Search for ‘\t’
Get: No ‘tab’ used in this document. And still the same error.
Use autopep8 -i test3 command.
Get:
The command autopep8 -i test3 completed normally. But when I run ‘test3’ it still gives the same error:
Traceback (most recent call last): File "c:\Users\Username\Documents\python\test3", line 1, in <module> import KNN File "C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\KNN.py", line 24 print(sortedDistIndicies[i]) TabError: inconsistent use of tabs and spaces in indentation
Use (Str + A) and press Shift + Tab
Get: Still same taberror.
That’s all I tried and got for now, thank you for reading my post.
Is there anything I can try to fix this?
Exactly what the error message says:
KNN.py, line 24 print(sortedDistIndicies[i]) TabError
Looking at the file at line 24 is a Tab character to indent 8 spaces.
Replace the Tab with 8 spaces, and while you are there also remove all the trailing Whitespace (Ctrl+K Ctrl+X in VSC)

mypy error on same line regardless of code content

I'm getting a mypy syntax error on line 36 in every single one of my files. If the file is shorter than 36 lines it just highlights the last line. The error is invariably the same:
invalid syntax mypy(error)
Apparently this issue may have happened before, but without a clear solution. Is this a known bug? How can I fix this?
Here is a clear example:
I found the reason: I have another file where there is a syntax mistake on line 36. Even though I closed that file, somehow mypy was still highlighting that same line in all of the files I had open. After I fixed that mistake in that one file, the mysterious syntax errors were gone in all the other files as well.
This seems like a bug to me, but I'm not sure if it's mypy or vscode (the IDE i'm using)? In any case my conclusion from this is: if you get inexplicable errors on the same line in all files, check for a mistake on that line even in closed files and fix it.

nvim-completion-manager: neovim shows a Python syntax error in cm.py when opening a new file, I despite no actual syntax error in file

In ~/.config/nvim/plugged/nvim-completion-manager/pythonx/cm.py, line 151 is
self.nvim.call('cm#complete', name, ctx, startcol, matches, refresh, async=True)
I'm using Python 3.8 and copying the file into an online interpreter for Python does not result in any syntax errors, so it confuses me that neovim is interpreting it as such.
I get Error detected while processing function <SNR>35_on_core_channel_error
My ~/.config/nvim/init.vim is
call plug#begin()
Plug 'roxma/nvim-completion-manager'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
call plug#end()
I tried replacing the leading spaces with tabs but I got the same output.
All of this is followed directly from https://www.linode.com/docs/guides/how-to-install-neovim-and-plugins-with-vim-plug/
File: https://onlinegdb.com/ByyfKgK6w (raises an error, but syntax is fine).
replace
Plug 'roxma/nvim-completion-manager'
with
Plug 'ncm2/ncm2'
in init.vim

Syntax error near unexpected token '(' after implementing python program

I initally ran RepeatMasker on a Mac, and I am attempting to analyze the file on a Linux OS.
When I try to run my program Unique_Repeat_Code.py:
RM_output=open('genomic.fna.out')
contents=RM_output.read'()'
unique_repeats_DNA=open('genomic_unique_repeats.txt','w')
for _ in contents:
bit_score=column[0]
percent_div=column[1]
percent_del=column[2]
percent_ins=column[3]
query_seq=column[4]
position_query_begin=column[5]
position_query_end=column[6]
left=column[7]
sense=column[8]
matching_repeat=column[9]
repeat_class=column[10]
position_in_repeat_begin=column[11]
position_in_repeat_end=column[12]
left2=column[13]
ID=column[14]
while matching_repeat:
unique_repeats=set(matching_repeat)
unique_repeats_DNA.write(unique_repeats)
unique_repeats_DNA.close()
in terminal I get the following error:
./Unique_Code.py: line 6: syntax error near unexpected token '('
./Unique_Code.py: line 6: 'RM_output=open('genomic.fna.out')'
Any help in fixing this problem would be appreciated. Thank you in advance!
You are running your script as a bash script when you use the "./" syntax. You need to use the python interpreter to run your script:
python Unique_Code.py

Categories

Resources