Issue installing scipy: Six module not found - python

Question similar to this one Issues installing scipy from Anaconda2 Python but I don't have anaconda so the answer there won't work for me.
I'm trying to install 64 bit Scipy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy but I'm getting this error:
from scipy._lib.six import string_types
ImportError : No module named scipy._lib.six
The _lib folder does contain a python file called six, though. And I have the Six package installed elsewhere already?
EDIT: I've been told it's probably something to do with the python path. Can anyone help?

it's probably solved for you by now but you also need the file called six.pyc. If it's not there, it's probably in usr/local/lib/python2.7/dist-packages/scipy. (or replace python2.7 with whatever version you have). Just copy it to scipy._lib, but make sure you choose the right scipy (there could be a usr/local/lib/python2.7/dist-packages/scipy AND a usr/lib/python2.7/dist-packages/scipy (without the local))

Related

Python: No module named 'numpy'

I tried to import numpy but I received a ModuleNotFoundError: No module named 'numpy' error. Someone told me it could be because I didn't have numpy installed, but I already did.
upon installing numpy I got Requirement already satisfied: numpy in ./opt/anaconda3/lib/python3.8/site-packages.
which python returns /Users/MacBook/opt/anaconda3/bin/python. I am new at this, but I'm guessing the reason I got that error was because the files aren't in the same place? If so, how do I move it to the right place?
side note: I have a similar issue with matplotlib and this is running on VS code if that helps. Also I use spyder and I don't get the numpy nor the matplotlib error over there, but the error seems to be on VS code
Try uninstalling numpy and re-installing. You also try re-install anaconda. I had this same issue and that fixed it.
Anaconda installs its own conda environment to run python. Probably VS Code can't access. Try this command;
python -mpip install numpy
If your python file named numpy.py, you can get this error too.
If doesn't work maybe you can try to change the environment to Anaconda environment.
check this

ImportError: No module named spwd

Could someone help, please? I can't understand why I see this.
I'm trying to use spwd module from Python. I just imported it, but see this, absolutely unexpected, error when running:
Traceback (most recent call last):
File "./library/system_users.py", line 25, in <module>
import spwd
ImportError: No module named pwd
I thought it should be available by default.
Python 2.7.10
pip 8.1.1 from /Library/Python/2.7/site-packages (python 2.7)
OS X El Capitan 10.11.4
I know sometimes pip install --upgrade pip can help. Unfortunately, not now.
Thank you for the advance.
As you guessed in your comment on this question, spwd is a built-in module, so it is usually built as you compile Python. For this reason, I would guess that spwd simply isn't supported on the system you are using—i.e. OS X 10.11—unless whoever built your installed version of Python made a configuration mistake or manually disabled the module.
However, we can do more than guess about this. When building Python, much of the system-specific configuration is handled in a script called setup.py. Support for many built-in modules is determined in the detect_modules method of the PyBuildExt class; the function contains the following code (taken from here).
if (config_h_vars.get('HAVE_GETSPNAM', False) or
config_h_vars.get('HAVE_GETSPENT', False)):
exts.append( Extension('spwd', ['spwdmodule.c']) )
else:
missing.append('spwd')
We can see that the function adds the Extension 'spwd' (which consists of the spwdmodule.c source file) to the lists of extensions only when config_h_var has either HAVE_GETSPNAM or HAVE_GETSPENT. The strings in config_h_vars correspond to the macros that are defined in the pyconfig.h header file that is generated when you run Python's configure script before compiling.
According to comments generated with the pyconfig.h file, HAVE_GETSPNAM is defined (to 1) if your system has the getspname function, and HAVE_GETSPENT is defined (again, to 1) if your system has the getspent function.
The problem is that OS X 10.11 (and, seemingly, newer versions of macOS) have neither of these functions. (The manual for gnulib confirms this, albeit for an older version of Mac OS X. See this page and this page.) Thus, when compiling Python on OS X/macOS, the spwd is not built, and so you see an ImportError when you try to import it on that system.
dooms's answer suggests installing spwd from Anaconda. Of course, this isn't expected to work since spwd is a built-in module, not a package you would expect to install from a package manager. I also don't see a spwd package on PyPI or any Anaconda channels.
However, since Python does not seem to prevent you from installing a module named spwd (at least when you don't have the built-in spwd), it is conceivable that you could install some sort of drop-in replacement spwd made for macOS. macOS and iOS use /etc/master.passwd instead of /etc/shadow, but maybe it might still be possible to make something work.
Unfortunately, as of this writing, it doesn't seem like any such replacement exists for macOS. I would treat any software that requires spwd as incompatible with macOS.
You should use Anaconda.
Anaconda is a completely free Python distribution (including for commercial use and redistribution). It includes more than 400 of the most popular Python packages for science, math, engineering, and data analysis. See the packages included with Anaconda and the Anaconda changelog.
After that, just type :
conda install spwd

Matplotlib: Import Error no module named _path

I've been struggling for hours on a problem that is making me insane. I installed Python 2.7 with Cygwin and added Scipy, Numpy, Matplotlib (1.4.3) and Ipython. When I decided to run ipython --pylab I get the following error:
/usr/lib/python2.7/site-packages/matplotlib/transforms.py in <module>()
37 import numpy as np
38 from numpy import ma
----> 39 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
40 update_path_extents)
41 from numpy.linalg import inv
ImportError: No module named _path
I spent hours on the internet, looking for a solution but nothing worked. I did notice that I am missing _path.so files in the matplotlib directory that everybody seems to have. Instead, I have two files: path.py and path.pyc. But I installed matplotlib directly from the official website using pip install and reinstalling it didn't make any difference. Does anyone have a little clue on what is going wrong? I would be incredibly grateful !!!
For others having this problem, in my case, the solution was simple. The problem was caused by having the wrong matplot library installed on your computer; creating an error in finding the correct matplotlib path. In my case, I had installed matplotlib on a different version of python. Simply update matplotlib on your computer, so that it is compatible with your current version of python:
pip install --upgrade matplotlib
As for the post, I am unsure of what caused these big issues. Hope my tip can help anyone else stumbling upon this issue!
I doubt that most of you brought here by Google have the problem I had, but just in case:
I got the above "ImportError: No module named _path" (on Fedora 17) because I was trying to make use of matplotlib by just setting sys.path to point to where I had built the latest version (1.5.1 at the time). Don't do that.
Once I ran "python setup.py install" (as root) to do a proper install (and got rid of my sys.path hack), the error was fixed.
The package matplotlib requires multiple dependencies (see them here). For me, the missing dependencies included pyparsing and kiwisolver, but your results my vary. Before you do any of these other things (reinstalling python or the library, etc...), make sure you have installed (pip install ...) all the libs in this list (link).

How to get _sqlite3.so file?

I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by default in the considered version of Python. However, I have some troubles. When I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "", line 1, in File "/home/verrtex/opt/lib/python2.6/sqlite3/init.py", line 24, in
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: No module named _sqlite3
As I have already told to, the possible reason of this problem is that the module in tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. This explanations is supported by the fact that I do not have _sqlite3.so file in my "/home/verrtex/opt/lib/python2.6/lib-dynload" directory. So, this is the problem I have to solve (I have to get this file to this directory).
I found out that to solve this problem I have to "install sqlite3 and recompile Python". I also found out that the problem can be solved by "building from source and moving the library to /usr/lib/python2.5/lib-dynload/".
However, it is not clear to me what exactly should I do. Should I install python module called "sqlite3" or I should install sqlite-database? By the way, I have already sqlite-database installed globally by the administrator. Can I use it or I still have to install my own database? By the way, I do not have root permissions. Can it be a problem? Or I need to install a python module? Is absence of root permissions a problem, in this case?
I also has been told to, to take source files from SQLite Download Page, extract archive, move to expanded directory and execute:
./configure
make
make install
Then I have to copy newly compiled files to my Python directory. Should I copy all newly compiled files? And to which exactly directory should I copy (my Python directory have some subdirectories)?
Would very appreciate any help, because I stack with this problem for a wile.
P.S. My OS is CentOS release 5.3 (Final).
Your sys.path is likely not pointing to your locally installed copy, or you're not running the Python 2.6.2 you think you are.
If none of that is the case, you need the SQLite development headers (sqlite-dev or whatever), and then recompile Python. You need to pay attention at the end of the compile, because it complains about what it didn't build due to missing dependencies.
EDIT: Reread question.
EDIT 2: Also, please don't do this:
from module import *
Do this:
from module import what_i_need
import module2
Although you might have found your solution, I just wrote mine down for someone who are stuck in the same problem.
My OS is CentOS 6.3(Final) with python2.6.
I install python2.7.3 in my system, but the problem's still there. (_sqlite3.so should be in /path/to/python2.7.3/lib/python2.7/lib-dynload after python2.7.3 has been installed. Because before python2.7 was installed, sqlite-autoconf-3071502.tar.gz was installed.)
I then copy the /path/to/python2.6/lib/python2.6/lib-dynload/_sqlite3.so to the python2.7's path. And type in the python-shell:
>>> import sqlite3
or
>>> import _sqlite3
No error reports.
Unfortunately, the damn error appeared as before when I run my python script.
I install sqlite-devel(sudo yum install sqlite-devel or download here), and then reinstall python2.7.3 again. Run my python script again. Thank goodness! The damn error finally solved.

How to find out if I have installed a Python module in Linux?

I tried to install a Python module by typing: sudo python setup.py install
After I typed this command I got a lot of output to the screen.
The lest few lines are bellow:
writing manifest file 'scikits.audiolab.egg-info/SOURCES.txt'
removing '/usr/lib/python2.5/site-packages/scikits.audiolab-0.10.2-py2.5.egg-info' (and everything under it)
Copying scikits.audiolab.egg-info to /usr/lib/python2.5/site-packages/scikits.audiolab-0.10.2-py2.5.egg-info
Installing /usr/lib/python2.5/site-packages/scikits.audiolab-0.10.2-py2.5-nspkg.pth
running install_scripts
So, there were nothing suspicious. But when I tried to use the module from the Python:
import pyaudiolab
I see that Python does not find the module:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pyaudiolab ImportError: No module named pyaudiolab
How can I found out what went wrong? As a result of the installation I get a new directory:
/usr/lib/python2.5/site-packages (so something happened) but I still cannot use the module. Can anybody help me with that?
Have you tried import scikits.audiolab or import audiolab?
From the OP's comment to an answer, it's clear that scikits.audiolab is indeed where this module's been installed, but it also needs you to install numpy. Assuming the module's configuration files are correct, by using easy_install instead of the usual python setup.py run, you might have automatically gotten and installed such extra dependencies -- that's one of the main points of easy_install after all. But you can also do it "manually" (for better control of where you get dependencies from and exactly how you install them), of course -- however, in that case, you do need to check and manually install the dependencies, too.
Your library depends upon numoy. Try installing numpy:
sudo apt-get install python-numpy
You need a more recent version of numpy (>= 1.2.0), as indicated on the audiolab installation informations.
check if you have the module somewhere inside:
/usr/lib/python2.5/site-packages/
(search for a file named |modulename|.py so in your example - try: pyaudiolab.py or audiolab.py)
if it exists - check if the directory in which it exists is found in the sys.path variable:
import sys
sys.path

Categories