How to install scipy with pip3? - python-3.x

I got the following error when I try to install scipy with pip3 on Mac OS X 10.14.1. Does anybody know what the problem is? I was able to install scipy with pip2.
$ pip3 install scipy
Collecting scipy
Using cached https://files.pythonhosted.org/packages/ee/5b/5afcd1c46f97b3c2ac3489dbc95d6ca28eacf8e3634e51f495da68d97f0f/scipy-1.3.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/mktemp/tmp9rjyv64p
cwd: /private/tmp/mktemp/pip-install-w63x23dy/scipy
Complete output (50 lines):
setup.py:386: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/tmp/mktemp/pip-install-w63x23dy/scipy/pip-wheel-metadata'), proceeding with generating Cython sources and expanding templates
warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
Traceback (most recent call last):
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: dlopen(/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so, 2): Symbol not found: _aheapsort_bool
Referenced from: /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
Expected in: flat namespace
in /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 69, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 156, in prepare_metadata_for_build_wheel
self.run_setup()
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 236, in run_setup
super(_BuildMetaLegacyBackend,
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 505, in <module>
setup_package()
File "setup.py", line 481, in setup_package
from numpy.distutils.core import setup
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: dlopen(/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so, 2): Symbol not found: _aheapsort_bool
Referenced from: /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
Expected in: flat namespace
in /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/mktemp/tmp9rjyv64p Check the logs for full command output.
WARNING: You are using pip version 19.2.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Related

ImportError: cannot import name '_adapters' from partially initializer module importlib_metadata' (most likely due to a circular import)

I was updating my Pypi package using:
python setup.py sdist bdist_wheel
Then, running:
python -m twine upload --https://github.com/ERijck/FuzzyTM https://test.pypi.org/legacy/ dist/*
Returned the following error:
(base) C:\Users\Emil\surfdrive\PhD\3. Python Scripts\GitHub\FuzzyTM>python -m twine upload --https://github.com/ERijck/FuzzyTM https://test.pypi.org/legacy/ dist/*
Traceback (most recent call last):
File "C:\Users\Emil\Anaconda3\lib\runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Emil\Anaconda3\lib\runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\Emil\Anaconda3\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\Emil\AppData\Roaming\Python\Python38\site-packages\twine\__init__.py", line 32, in <module>
import importlib_metadata
File "C:\Users\Emil\Anaconda3\lib\site-packages\importlib_metadata\__init__.py", line 17, in <module>
from . import _adapters, _meta
ImportError: cannot import name '_adapters' from partially initialized module 'importlib_metadata' (most likely due to a circular import) (C:\Users\Emil\Anaconda3\lib\site-packages\importlib_metadata\__init__.py)
Based on the error and on this link it seems that I have a circular import. How can I fix this?
The problem was not a circular input. Having an older version of importlib_metadata installed caused the issue.
pip install -U importlib_metadata solved it.

Distutils was imported before Setuptool error

After upgrading pip on python3.5 I am getting the message
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 57 sys.stderr.write(f"ERROR: {exc}")
I tried the solution in
pip: sys.stderr.write(f"ERROR: {exc}") with Python 3.5
However when I try
sudo curl -fsSL https://bootstrap.pypa.io/pip/3.5/get-pip.py | python3.5
I get
/usr/local/lib/python3.5/dist-packages/_distutils_hack/__init__.py:18:
UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.`
`"Distutils was imported before Setuptools, but importing Setuptools "
/usr/local/lib/python3.5/dist-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
File "<stdin>", line 23974, in <module>
File "<stdin>", line 199, in main
File "<stdin>", line 121, in bootstrap
File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 8, in <module>
import _distutils_hack.override # noqa: F401
File "/usr/local/lib/python3.5/dist-packages/_distutils_hack/override.py", line 1, in
<module>
__import__('_distutils_hack').do_override()
File "/usr/local/lib/python3.5/dist-packages/_distutils_hack/__init__.py", line 72, in do_override
ensure_local_distutils()
File "/usr/local/lib/python3.5/dist-packages/_distutils_hack/__init__.py", line 59, in ensure_local_distutils
assert '_distutils' in core.__file__, core.__file__
AssertionError: /usr/lib/python3.5/distutils/core.py ```
Any ideas?

How to solve the metadata wheel error during installation of pyqt5 with pip

I recently installed a virtual environement using pyvenv in Python and it worked fine until I needed to install PyQt5.
After that I also tried installing directly but it gave me other problems too related to SIP
My operating system is Ubuntu 14.04 32 bit,
I ran:
sudo -H python3 -m pip install pyqt5
The output was:
Collecting pyqt5
Using cached PyQt5-5.15.0.tar.gz (3.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3 /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpkqu84tmx
cwd: /tmp/pip-install-d7z8r80t/pyqt5
Complete output (35 lines):
Querying qmake about your Qt installation...
/usr/bin/qmake -query
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 126, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
main()
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 131, in prepare_metadata_for_build_wheel
config_settings)
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 159, in _get_wheel_metadata_from_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/abstract_project.py", line 82, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/project.py", line 477, in setup
self.apply_user_defaults(tool)
File "project.py", line 62, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/project.py", line 223, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/pyqtbuild/builder.py", line 76, in apply_user_defaults
self._get_qt_configuration()
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/pyqtbuild/builder.py", line 445, in _get_qt_configuration
"v{0}".format(self.qt_version_str))
sipbuild.exceptions.UserException
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3 /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpkqu84tmx Check the logs for full command output.

Slycot fails to import when using control

I cannot seem to get the control.ss2tf() function to work for state space MIMO system. The function works perfectly for a SISO system.
The following code is used to run the module:
control.ss2tf(A,B,C,D)
The resulting output indicated that the slycot module was not installed.
I then tried installing slycot with
pip install slycot
This command gave the following output:
Failed building wheel for slycot
Running setup.py clean for slycot
Failed to build slycot
Installing collected packages: slycot
Running setup.py install for slycot ... error
Complete output from command c:\users\wian\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Wian\\AppData\\Local\\Temp\\pip-install-cmcxwtts\\slycot\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Wian\AppData\Local\Temp\pip-record-_n6gj2yv\install-record.txt --single-version-externally-managed --compile:
Running from numpy source directory.
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
building extension "slycot._wrapper" sources
f2py options: []
adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6\slycot\src\fortranobject.c' to sources.
adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6\slycot\src' to include_dirs.
adding 'build\src.win-amd64-3.6\slycot\src\_wrapper-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_py
copying slycot\version.py -> build\lib.win-amd64-3.6\slycot
copying build\src.win-amd64-3.6\slycot\__config__.py -> build\lib.win-amd64-3.6\slycot
running build_ext
Looking for python36.dll
Building import library (arch=AMD64): "c:\users\wian\anaconda3\libs\libpython36.a" (from c:\users\wian\anaconda3\python36.dll)
objdump.exe: c:\users\wian\anaconda3\python36.dll: file format not recognized
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Wian\AppData\Local\Temp\pip-install-cmcxwtts\slycot\setup.py", line 241, in <module>
setup_package()
File "C:\Users\Wian\AppData\Local\Temp\pip-install-cmcxwtts\slycot\setup.py", line 233, in setup_package
setup(**metadata)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\core.py", line 171, in setup
return old_setup(**new_attr)
File "c:\users\wian\anaconda3\lib\site-packages\setuptools\__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "c:\users\wian\anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\install.py", line 62, in run
r = self.setuptools_run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "c:\users\wian\anaconda3\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "c:\users\wian\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\build.py", line 47, in run
old_build.run(self)
File "c:\users\wian\anaconda3\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\wian\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\build_ext.py", line 116, in run
force=self.force)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\ccompiler.py", line 765, in new_compiler
compiler = klass(None, dry_run, force)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 103, in __init__
build_import_library()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 415, in build_import_library
return _build_import_library_amd64()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 471, in _build_import_library_amd64
generate_def(dll_file, def_file)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 301, in generate_def
raise ValueError("Symbol table not found")
ValueError: Symbol table not found
I read that this is due to a FORTRAN compiler not installed on the system. I therefore installed gfortran with Ming32. To verify the install I ran the following:
(base) C:\WINDOWS\system32>gfortran
gfortran: fatal error: no input files
compilation terminated.
So gfortran is installed as a compiler, but yet pip remain unable to install slycot. I have also installed Microsoft Visual Studio 2017.
At this point I went to PyPi library to download the compiled binary of the slycot module. https://www.lfd.uci.edu/~gohlke/pythonlibs/
Here I downloaded the correct .whl file for my system (64 bit Python 3.6), and installed it with pip.
pip install "C:\Users\Wian\Desktop\slycot-0.3.3-cp36-cp36m-win_amd64.whl"
Using this command slycot 0.3.3 was installed successfully. However, when i run the command
control.ss2tf(A,B,C,D)
I get the following output
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\control\xferfcn.py in _convertToTransferFunction(sys, **kw)
1089 try:
-> 1090 from slycot import tb04ad
1091 if len(kw):
ImportError: cannot import name 'tb04ad'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-8-2b014ac15956> in <module>()
----> 1 control.ss2tf(Model)
~\Anaconda3\lib\site-packages\control\xferfcn.py in ss2tf(*args)
1315 sys = args[0]
1316 if isinstance(sys, StateSpace):
-> 1317 return _convertToTransferFunction(sys)
1318 else:
1319 raise TypeError("ss2tf(sys): sys must be a StateSpace object. It \
~\Anaconda3\lib\site-packages\control\xferfcn.py in _convertToTransferFunction(sys, **kw)
1113 # If slycot is not available, use signal.lti (SISO only)
1114 if (sys.inputs != 1 or sys.outputs != 1):
-> 1115 raise TypeError("No support for MIMO without slycot")
1116
1117 # Do the conversion using sp.signal.ss2tf
TypeError: No support for MIMO without slycot
When I try to import slycot in Python, I get the following result:
>>> import slycot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Wian\Anaconda3\lib\site-packages\slycot\__init__.py", line 18, in <module>
from .analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, \
File "C:\Users\Wian\Anaconda3\lib\site-packages\slycot\analysis.py", line 21, in <module>
from . import _wrapper
ImportError: DLL load failed: The specified module could not be found.
There is a _wrapper.pyd file in the Slycot directory (under Anaconda3\Libs\site-packages).
This is where I am currently stuck, and I cannot get Slycot to import correctly.
Your help is greatly appreciated!

Can not run virtualenv successfully on win10

I use python36 and win10, I can install virtualenv successfully. But when I want to activate it, some mistakes have occurred.
$pip install virtualenv
Requirement already satisfied: virtualenv in c:\users\appdata\local\programs\python\python36\lib\site-packages
$virtualenv venv
Using base prefix 'c:\\users\\appdata\\local\\programs\\python\\python36'
New python executable in C:\Users\myvenv\venv\Scripts\python.exe
Installing setuptools, pip, wheel...
Complete output from command C:\Users\myvenv\venv\Scripts\python.exe - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
ModuleNotFoundError: No module named 'pkgutil'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "c:\users\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\AppData\Local\Programs\Python\Python36\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "c:\users\appdata\local\programs\python\python36\lib\site-packages\virtualenv.py", line 713, in main
symlink=options.symlink)
File "c:\users\appdata\local\programs\python\python36\lib\site-packages\virtualenv.py", line 945, in create_environment
download=download,
File "c:\users\appdata\local\programs\python\python36\lib\site-packages\virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "c:\users\appdata\local\programs\python\python36\lib\site-packages\virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command C:\Users\myvenv\venv\Scripts\python.exe - setuptools pip wheel failed with error code 1
Why is there such a problem?
In fact, you don't need to reinstall your python, instead, you can just entry virtualenv envname --no-setuptools --no-pip --no-wheel in your cmd line, hope be helpful.

Resources