Import os doesn't not work in linux - python

I just want to install the suds library, but suddenly it wasn't proceeding because it was not finding the os library, so I tried to open my python and it results me an error. When I import the os library and there are some errors during the opening as well. Please, see the snapshot of my error when importing the library mentioned.
Is there any solution for this? Or do I need to reinstall python?

You need to install a more recent version of Python - version 2.7.12 or later. All versions of Python 2.6 have been end-of-lifed and any use of Python 2.6 is actively discouraged.

Related

Outdated hashlib module in a non-current version of Python

I installed a python package that I need, and tried to import it, but there's a line of code in the package:
from hashlib import blake2s
which returned the error:
ImportError: cannot import name 'blake2s'
After a bit of reading, I found that the hashlib module in Python 3.6+ has blake2s, but I'm using Python 3.5.6. Updating my Python version would solve this problem, but I don't have admin access on this system. So I'm stuck on Python 3.5.6.
Is there a way to get blake2s working in Python 3.5?
edit: I'm wondering if this can be used somehow...
https://github.com/dchest/pyblake2
Answering my own question...
I installed the pyblake2 package (linked in my edit above), then went inside the package I was trying to install and modified the import line.
I changed
from hashlib import blake2s
to
from pyblake2 import blake2s
and then reinstalled the package with that modified line.
It worked! The package is working in Python 3.5 even though Python 3.5 hashlib does not have blake2s.

Difficulty getting Python 3.3 and numpy to work

I'm newer to python, but have seem to screwed things up trying out the new python.
I have an older mac which runs python 2.5 as it's default. I've installed python 3.3. However, when I upgraded numpy my python 2.5 now gives me the:
Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
regardless of the directory I run python from. And python 3.3 can't find the numpy module. Did I miss something? How can I get 2.5 running numpy again and get python 3.3 to find the module?
I also can't get virtualenv to work as it gives me the error that the script needs python2.6, even after I installed virtualenv-2.5 and can't get the python=python3.3 to do anything either. I seem to have tried everything I can find. I'm afraid I've installed too much and have some hidden conflict.
Thanks
download numpy from this site : http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
In case you want to check the version of numpy on your system , write this following code on your IDE :
import numpy
numpy.version.version
Hope this would help !

Can't get import to be recognized - jsonpickle

I am using PyDev via eclipse and have used easy_install to get jsonpickle. No matter what I do I can't seem to get the import to work.
What I have tried thus far:
I have removed it from easy_install.pth and deleted the egg and installed again.
Add my python lib, dll, etc folders to a PYTHONPATH system variable
Restarted eclipse
Other imports are working fine. Not sure what I am doing wrong?
EDIT:
Sorry should have included OS / Python version.
OS: Windows 7
Python: 2.7
Any suggestions greatly appreciated
OS and python version?
Please use pip. Always.
pydev seems to ignore your package. It should be in /usr/share/pythonX.Y/site-packages/jsonpickle, or, if on Windows, c:\pythonxx[...].
If using Linux, please try to find a distro package for jsonpickle.

How do I 'down grade' to python2.7

Being quite cavalier I went for the latest version of Python (3.2.2)
Unfortunately it lacks the matplotlib that I desperately need.
I have downloaded python 2.7.
My simple question is weather I have to uninstall python3.2 or can I leave it on my windows 64 system?
you can keep the python 3.2 installation, but you will have to be carefull about which version you launch (by making the call explicit). you can always check the python version in a script by doing:
import sys
print sys.version
If you have no particular use of python 3.2, I recommend uninstalling it.
I'm not sure if there's a difference on python in windows but on mac and linux I simply call older versions using
python2.6 or python2.7
It seems to keep all the versions I previously had before. Maybe try running the above command and seeing if it works on windows and if it does just change the symbolic link 'python' is pointing to.

`Fatal Python error: PyThreadState_Get: no current thread` after `import cv´

I installed OpenCV via sudo brew install opencv.
Then I added PYTHONPATH* to my ~/.profile as brew info opencv says**. With env I checked that the path was loaded.
Now everytime I try to import cv, Python gives following error: Fatal Python error: PyThreadState_Get: no current thread Abort trap.
What should I do?
*PYTHONPATH=/usr/local/lib/python2.7/site-packages/:
** actually, it points to folder python2.6 but 2.7 is the Python version I use and cv 2.2. supports it.
cv 2.2 might well support it, but you MUST not mix versions like that. You must use the version built for 2.7 with 2.7, and the version built for 2.6 with 2.6
I seem to think that cv is a python library that depends on a C library - in that case, you can not mix the libraries like that.
cv will need to be re-compiled against 2.7 if you have only a 2.6 version of it.
That said, this type of Fatal Error suggests a bug in the cv library, however, if you're mixing versions like this, then the result is undefined. (It might work by chance, or it might fail randomly as it has for you).

Categories

Resources