How to fix Octave symbolic package error in Ubuntu 20.04? - python

I have installed the symbolic package. There are some python related errors in the command window of Octave when I try to use symbolic.Below is the output:
> pkg load symbolic
>> syms a
Symbolic pkg v2.9.0: Traceback (most recent call last):
File "<stdin>", line 28, in <module>
AttributeError: '_PrintFunction' object has no attribute '__globals__'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 12, in octoutput_drv
File "<stdin>", line 54, in octoutput
File "<stdin>", line 55, in octoutput
AttributeError: module 'sympy' has no attribute 'compatibility'
Closing the Python communications link.
error: Python exception: AttributeError: '_PrintFunction' object has no attribute '__globals__'
occurred in python_header import block.
Try "sympref reset" and repeat your command?
(consider filing an issue at https://github.com/cbm755/octsympy/issues)
error: called from
pycall_sympy__ at line 191 column 5
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
>> Opening in existing browser session.
Any idea how i can troubleshoot this?
Thanks.

The error is a known bug (https://github.com/cbm755/octsympy/issues/1035)
You need to use an older version of sympy sunch as version 1.5.1

Related

can't import ethjsonrpc in python3.6 , ubuntu

when importing ethjsonrpc It throws an error as below:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/__init__.py", line 1, in <module>
from ethjsonrpc.client import (EthJsonRpc, ParityEthJsonRpc,
File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/client.py", line 7, in <module>
from ethereum import utils
File "/usr/local/lib/python3.6/site-packages/ethereum/utils.py", line 103, in <module>
assert sha3('').encode('hex') == 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
AttributeError: 'bytes' object has no attribute 'encode'
This is an issue with ethjsonrpc as can be seen on the github issue page. The proposed fix is to just comment the line 103 in /usr/local/lib/python3.6/site-packages/ethereum/utils.py
Might be a good idea to switch to using this module with python2 instead in case more errors appear that are caused by version differences.

Not able to open and load pickle file in python 3.6.1

I am trying to open and load pickle file but by two ways. But every time I am getting an error.
Request you to please help.
First way :
enron_data = pickle.load(open("D:/New/ud120-projects/final_project/final_project_dataset.pkl", "r"))
Error: Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
Second Way :
enron_data = pickle.load(open("D:/New/ud120-projects/final_project/final_project_dataset.pkl", "rb"))
Error : Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_pickle.UnpicklingError: the STRING opcode argument must be quoted
Request you to please help
If you are on Windows you have to use a raw string and backslashes like this:
r'D:\path\to\your\file'

Is it a PyVISA installation failure ? Or, am I doing something wrong?

I wanted to test my PyVISA installation and got a certain failure:
>>> import visa
>>> rm = visa.ResourceManager()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python35\lib\site-packages\pyvisa\highlevel.py", line 1
488, in __new__
visa_library = open_visa_library(visa_library)
File "C:\Program Files\Python35\lib\site-packages\pyvisa\highlevel.py", line 1
460, in open_visa_library
return cls(argument)
File "C:\Program Files\Python35\lib\site-packages\pyvisa\highlevel.py", line 9
6, in __new__
raise OSError('Could not open VISA library:\n' + '\n'.join(errs))
OSError: Could not open VISA library:
>>>
What could be my problem ?
I have tried to update the VISA path:
>>> rm = ResourceManager('C:\Program Files\Python35\Lib\site-packages')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ResourceManager' is not defined
>>> visalib = VisaLibrary('C:\Program Files\Python35\Lib\site-packages')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'VisaLibrary' is not defined
>>> rm = ResourceManager('C:/Program Files/Python35/Lib/site-packages')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ResourceManager' is not defined
>>> import visa
>>> rm = ResourceManager('C:\Program Files\Python35\Lib\site-packages')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ResourceManager' is not defined
>>>
Without any success
PyVISA is only Python wrapper for DLL which standard location is somewhere in Windows. For example at my PC is C:\Windows\System32\visa64.dll.
At my code i use rm = visa.ResourceManager(C:\\Windows\\System32\\visa64.dll)
Of course first time you have to get VISA library which is part of huge NI-VISA installation package which you can found here:
NI-VISA Download Installer

Getting TypeError while importing urllib

When I write the following line of code
import urllib
I get this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib.py", line 26, in <module>
import socket
File "socket.py", line 2, in <module>
s = socket.socket()
TypeError: 'module' object is not callable
After going through various questions on SO I tried these:
from urllib import urlopen
(Same error as above)
>>> urllib
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
>>> urllib.urlopen()
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
Please help. I get a similar error when I try to import urllib2, urllib3, requests.
You named your file socket.py, hiding the standard library socket module. Name it something else.

Pydoc not working in Python 3.3 in Windows

I am trying to generate the help text at runtime and i am not able to use the pydoc command in Windows. When i type
>>> pydoc(atexit)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'pydoc' is not defined
I have already set up the environment variables for pydoc.py file. C:\Python33\Lib\pydoc.py.
This also not works like it works for >>help('atexit')
>>> pydoc('atexit')
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'pydoc' is not defined
Whats the possible reason for it.
Updates:
>>> import pydoc
>>> pydoc(sys)
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'module' object is not callable
>>> pydoc('sys')
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'module' object is not callable
Like any library in Python, you need to import it before you can use it.
Edit What exactly are you trying to achieve? Modules are indeed not callable. pydoc.help is the function you want, although I don't really know why you need it, since as you note the standalone help function does the same thing already.

Categories