Base65536 in Python? - python

i've just installed base65536 in python, found Here
As a test to see if it works, i've made this script here:
import base65536
a = base65536.encode("Hello World")
print a
i'm using python2.7. When i run it, i get this error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
a = base65536.encode("Hello World")
File "C:\Python27\lib\site-packages\base65536\core.py", line 118, in encode
stream.write(unichr(code_point))
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
Any idea what to do here?

Python2 has two builds: one "narrow" and one "wide", depending on Unicode support. It looks like that library doesn't support the "narrow" build. You should install a "wide" build or hope the library gets updated. It looks like someone filed an issue on it: https://github.com/Parkayun/base65536/issues/4
Or you can use a recent version of Python3, which doesn't have this problem.

Related

import yaml missing error module

>>> import yaml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tools/python_libs/yaml/__init__.py", line 2, in <module>
from error import *
ModuleNotFoundError: No module named 'error'
I don't see how to set my PYTHONPATH with anaconda3.
Am I missing an install step?
I have the same situation, but with the ROS. The same error reproduces when you use python 3 instead of python 2. You can see corresponding discussion
here. For some reasons I would like to use python3 instead of python2, so I need to find out, how to get rid of this error.
I can suggest two solutions right now:
Either use python2 instead of python3, as suggested in ROS discussion
Or try to install yaml with pip3 for python3 (not pip). I think it may help in this situation. See here for installation instructions.

Trouble using Javabridge with Python

I successfully installed javabridge using $pip3 install javabridge on my Mac's virtual environment. But when I tried to import javabridge in my python3 code, this is what I get:
import javabridge
Failed to run /usr/libexec/java_home, defaulting to best guess for Java
Traceback (most recent call last):
File "/Users/puifai/Documents/data_science/venv/venv3/lib/python3.6/site-packages/javabridge/locate.py", line 45, in find_javahome
os.path.join(os.path.dirname(path), "Libraries"),
File "/Users/puifai/Documents/data_science/venv/venv3/bin/../lib/python3.6/posixpath.py", line 92, in join
genericpath._check_arg_types('join', a, *p)
File "/Users/puifai/Documents/data_science/venv/venv3/bin/../lib/python3.6/genericpath.py", line 151, in _check_arg_types
raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components
Any ideas on how to fix this? It looks like a problem with Python rather than javabridge?
Pardon the less-than-complete answer, but it has to do with the difference in strings between Python2 and Python3. Working in Python2.7 will at least get you around the problem for the moment. See this post for more background.

Error when I install samtools for python on windows

I am trying to install pysam and pybedtools modules on python 3.4. But I got an Error:
Collecting pysam
Using cached pysam-0.9.0.tar.gz
Complete output from command python setup.py egg_info:
'.' is not recognized as an internal or external command,
operable program or batch file.
# pysam: htslib mode is shared
# pysam: htslib configure options: None
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ikirov.CLO\AppData\Local\Temp\pip-build-_me_xeme\pysam\setup.py", line 212, in <module>
sys.abiflags)]
AttributeError: 'module' object has no attribute 'abiflags'
Could you please help me with it?
Hi I got the same error last year during one of my class.
As I know back then, pysam simply won't work with python3 + windows environment.
See this: https://github.com/pysam-developers/pysam/issues/353 looks like it is still unsolved now.
For my homework, I just used this http://bow.codeplex.com/
And my suggestion, just try to use linux or get a python2. Yes I know the scientific field is the slowest for the 2->3 transition. It sucks.

What is the easiest way to install OpenVAS omblib with Python?

I have followed https://pypi.python.org/pypi/openvas.omplib#installing-openvas-omplib with no luck. Below is the code they suggest (I used):
from openvas.omplib import *
manager = openvas.omplib.OMPClient(host = sensor)
manager.open(USER,PASSWORD)
I get the following error:
Traceback (most recent call last):
File "test.py", line 5, in <module>
manager = openvas.omplib.OMPClient(host=sensor)
NameError: name = 'openvas' is not defined
It seems the library is not installing correctly or all the way. To install, I ran:
easy_install openvas.omplib
Any ideas?
I have also tried Openvas_lib 1.0 (another form). This one also runs into errors. (yes I have the variables set to something)
from openvas_lib import VulnscanManager, VulnscanException
scan = VulnscanManager("localhost",USER,PASSWORD,9392)
scan.launch_scan(target,profile="empty")
Here is an image of my errors
It seems openvas wasn't updated for Kali 2.0 yet. However, openvas_lib works perfectly on Kali's older version. Hopefully they update openvas_lib for the newer version of kali soon.

Python - Zero length field name in format

I'm using Python on my Centos machine and when I try to run my program I have this error displayed :
Running setup.py egg_info for package pyepr
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build-root/pyepr/setup.py", line 68, in <module>
print('using EPR C API sources at "{}"'.format(eprsrcdir))
ValueError: zero length field name in format
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build-root/pyepr/setup.py", line 68, in <module>
print('using EPR C API sources at "{}"'.format(eprsrcdir))
ValueError: zero length field name in format
I have already checked the other questions about this subject and I already installed Python 2.7.6 and set it as my default configuration as shown below....
$ python -V
Python 2.7.6
Something must have gone wrong, but I don't know what.
Anybody has an idea?
Thanks
That error can only be raised if you run that code with Python 2.6 or older. In those versions, you must explicitly number the format fields for str.format (starting at 0):
print('using EPR C API sources at "{0}"'.format(eprsrcdir))
Of course, this is only a temporary fix. It would be better to investigate why your code is not being run with Python 2.7 in the first place and then fix that instead.
If you run an install using sudo, you are going to end up using the sudo path's Python interpreter. Not sure if you are using sudo or not for installing, but there is a good chance you are.

Categories