audiolab for python 2.7 - python

I have python 2.7 installed in my system and I need to use the audiolab module.
I downloaded from the following site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits.audiolab
When I import scikits.audiolab I get the following error:
Traceback (most recent call last):
File "C:/Python27/trystuff", line 1, in <module>
from scikits.audiolab import formatinfo as format
File "C:\Python27\lib\site-packages\scikits\__init__.py", line 1, in <module>
__import__('pkg_resources').declare_namespace(__name__)
ImportError: No module named pkg_resources
What should I do?

There is a Windows binary build of scikits.audiolab (and a whole lot of other stuff) for python 2.7 here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits.audiolab
audiolab will also require libsndfile. The link is right there on that page, but I'll put it here too since libsndfile is great:
http://www.mega-nerd.com/libsndfile/#Download
PS: You will need to put the libsndfile-1.dll someplace python can find it. If you don't mind wasting at tiny bit of disk space, you can drop a copy of it in the Python27\Lib\site-packages\scikits\audiolab\pysndfile directory.

You need pkg_resources module which is a part of setup_tools or the newer fork distribute. The site you linked also has Windows binaries for you to install. I'd recommend the distribute module. They also provide you easy install/uninstall capabilities for third-party modules.

Related

Windows scripting can't import ctypes module under Python 3.11.1

I just ran into a snag after upgrading to Python 3.11.1. Running Python 3.10.1 the ctypes module imports with no problems. Same under Windows scripting using the pywin32 package. With 3.11.1 importing ctypes directly still works. However, under Windows scripting using the pywin32 package import ctypes fails with the following error output:
E:\tmp\test2.pys(12, 0) Python ActiveX Scripting Engine: Traceback (most recent call last):
File "<Script Block >", line 12, in <module>
import ctypes
File "e:\Python\Lib\ctypes\__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Anyone else stumbled onto this problem?
I have found the solution. I added e:\Python\DLLs to the PYTHONPATH environment variable, and now Windows scripting is able to import the ctypes module. I don't claim to know exactly what the cause of the problem was, but it seems that the communication between Python and the pywin32 package has changed, so that while previously Windows scripting was able to find _ctypes.pyd it can no longer do that unless I explicitly tell it where to look. Didn't have to do that before, but everything works again when I do it now.

Which package to install based only on import line

I am very new to Python, and I am attempting to reproduce an example (not necessary to answer the question). If all I have is import threading from within the code I assumed I could just run pip install threading however the module is not found. When I searched for a different package name in the Python package manager I came across hundreds. Why doesn't the pip command work, and how do I know which package to install?
My exact error
:\Users\king\Desktop\_REPOS\misc\stock_analysis\forex\python\pythonv2>python trading.py
Traceback (most recent call last):
File "trading.py", line 1, in <module>
import Queue #pip install queuelib
ImportError: No module named 'Queue'
Version info
Python 3.5 32bit (64 bit OS)
The first hit on google (search: python threading) actually gave me:
https://docs.python.org/2/library/threading.html (the URL itself already indicate it)
This means it's a library module so it should be already available to you without extra installs.
In case your Python is limited in a way and doesn't have it by default, please update your question with your Python version and way it was installed.
For future reference, you were mostly doing the right thing, a lot of modules have the same name as their import statements, but otherwise, in almost all case, a simple Google search will suffice.

Installing Numpy with OpenBLAS support in home directory

I'm installing a Python (2.7.8) environment locally in my home folder on a server, in order to use newer versions of Python and some of its libraries (Numpy, Theano) together with OpenBLAS. For this, I first installed Python in the folder usr in my home directory (/home/my_home/usr/) as described here:
https://mail.python.org/pipermail/tutor/2002-March/012903.html
The installation seems to have gone smoothly. I checked this by starting the Python interpreter, which displays the right version on startup.
Following this, I installed OpenBLAS into /home/my_home/opt folder as described here:
Compiling numpy with OpenBLAS integration
... which also didn't give me any errors. However, now when I try installing Numpy (according to the instructions in the above link), I get the following error:
Traceback (most recent call last):
File "setup.py", line 22, in <module>
import subprocess
File "/home/ext_sxc/usr/lib/python2.7/subprocess.py", line 427, in <module>
import select
ImportError: No module named select
I suppose the straightforward thing to do is to find the package for select, compile and install it. I'm not sure if this is the right thing to do because the last time I installed Python 2.7.6 locally in a home directory, there were no such errors. As I understand, the select module should have been installed along with Python.
This also happens when I try installing IPython in a similar way in my home folder. The library which gives the ImportError is different.
I'm wondering if these are related to a more general mistake I may have made while installing Python. I'd appreciate any advice on this issue. Please let me know if any additional information would help. Thanks!

Python - problem in importing new module - libgmail

I downloaded Python module libgmail from sourceforge and extracted all the files in the archive. The archive had setup.py, so I went to that directory in command prompt and did
setup.py install
I am getting the following error message
I:\libgmail-0.1.11>setup.py install
Traceback (most recent call last):
File "I:\libgmail-0.1.11\setup.py", line 7, in ?
import libgmail
File "I:\libgmail-0.1.11\libgmail.py", line 36, in ?
import mechanize as ClientCookie
ImportError: No module named mechanize
This may be trivial, but I am new to python. So plz guide what to do.
please note, I am using python 2.4 and using Windows-XP.
Thank you
MicroKernel
I think this lib depends on this one:
http://wwwsearch.sourceforge.net/mechanize/
Try installing it first.
You need to download and install the module called mechanize. Depending on your operating system (ie. Linux), your package manager probably has something for this, otherwise you will need to google it, and follow it's installation instructions.
easy_install mechanize
If this doesn't work, you need to fix your PATH environment variable to include path to your python installation directory\scripts. easy_install will save you a lot of time in future.
P.S.: Python 2.4 is 6 years old, you should really consider at least 2.6.

How can I import the sqlite3 module into Python 2.4?

The sqlite3 module is included in Python version 2.5+. However, I am stuck with version 2.4. I uploaded the sqlite3 module files, added the directory to sys.path, but I get the following error when I try to import it:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "sqlite3/__init__.py", line 23, in ?
from dbapi2 import *
File "sqlite3/dbapi2.py", line 26, in ?
from _sqlite3 import *
ImportError: No module named _sqlite3
The file '_sqlite3' is in lib-dynload, but if I include this in the sqlite3 directory, I get additional errors.
Any suggestions? I am working in a limited environment; I don't have access to GCC, among other things.
I had same problem with CentOS and python 2.4
My solution:
yum install python-sqlite2
and try following python code
try:
import sqlite3
except:
from pysqlite2 import dbapi2 as sqlite3
Did you install it? That often works better than messing with sys.path.
python setup.py install
If so, you should then find it.
If, for some reason, you can't install it, set the PYTHONPATH environment variable. Do not make a habit of messing with sys.path.
You will need to install pysqlite. Notice, however, that this absolutely does require a compiler, unless you can find binaries for it (and Python 2.4) on the net. Using the 2.5 binaries will not be possible.
You must ensure your sqlite, sqlite-devel, python-sqlite are installed correctly first and then recompile Python.

Categories