I am trying to run a python project that I have not written myself. This has required me to install a series of new libraries, but more importantly, it has required me to install Cython.
I think I've installed Cython succesfully at this point. I am using MinGW for my compiler. When I try to run the project I get the error
ImportError: Building module RayTrace failed: ['DistutilsPlatformError: Unable to find vcvarsall.bat\n']
As far as I've understood this is about setting the path for the compiler. I have created the distutils.cfg file that says MinGW is the compiler as well as put MinGW in Path.
Where do I go from here?
this is the complete traceback:
Traceback (most recent call last):
File "C:\Users\Marten\Python\DisperseIt\DisperseIt.py", line 5, in <module>
from DisperseProjectDisperseCtrlFrame import *
File "C:\Users\Marten\Python\DisperseIt\DisperseProjectDisperseCtrlFrame.py", line 12, in <module>
import SectionCalc
File "C:\Users\Marten\Python\DisperseIt\SectionCalc.py", line 10, in <module>
from RayTrace import CalcIndices
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyximport.py", line 431, in load_module
language_level=self.language_level)
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyximport.py", line 209, in load_module
inplace=build_inplace, language_level=language_level)
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyximport.py", line 186, in build_module
reload_support=pyxargs.reload_support)
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyxbuild.py", line 104, in pyx_to_dll
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\Cython\Distutils\build_ext.py", line 163, in run
_build_ext.build_ext.run(self)
File "C:\Python27\lib\distutils\command\build_ext.py", line 337, in run
self.build_extensions()
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\Cython\Distutils\build_ext.py", line 171, in build_extensions
self.build_extension(ext)
File "C:\Python27\lib\distutils\command\build_ext.py", line 496, in build_extension
depends=ext.depends)
File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python27\lib\distutils\msvc9compiler.py", line 271, in query_vcvarsall
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
ImportError: Building module RayTrace failed: ['DistutilsPlatformError: Unable to find vcvarsall.bat\n']
Related
I am trying to install scipy 1.0.0 in a conda env for another software called GATK.
I installed python 3.6.10 and numpy 1.17.5, which are said to be compatible with scipy 1.0.0 (both in the yml file provided by GATK)
However, when I tried installing via python setup.py build, it returns error message as below. I searched by seems like others are mostly struggling with scipy 1.1.0 or some other errors.
Really appreciate any help!
Thanks!
f2py: build/src.linux-x86_64-3.6/scipy/linalg/flapack.pyf
Reading fortran codes...
Reading file 'build/src.linux-x86_64-3.6/scipy/linalg/flapack.pyf' (format:free)
Traceback (most recent call last):
File "setup.py", line 418, in <module>
setup_package()
File "setup.py", line 414, in setup_package
setup(**metadata)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/core.py", line 171, in setup
return old_setup(**new_attr)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build.py", line 47, in run
old_build.run(self)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 142, in run
self.build_sources()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 159, in build_sources
self.build_extension_sources(ext)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 319, in build_extension_sources
sources = self.f2py_sources(sources, ext)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 535, in f2py_sources
+ ['--build-dir', target_dir, source])
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 425, in run_main
postlist = callcrackfortran(files, options)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 330, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 3251, in crackfortran
readfortrancode(files, crackline)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 501, in readfortrancode
dowithline(finalline)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 796, in crackline
analyzeline(m, pat[1], line)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 1098, in analyzeline
last_name = updatevars(typespec, selector, attr, edecl)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 1542, in updatevars
attrspec = [x.strip() for x in markoutercomma(attrspec).split('#,#')]
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 833, in markoutercomma
assert not f, repr((f, line, l))
AssertionError: (-1, 'intent(in))', 'intent(in))')```
- List item
I'm using Python 3.8 and I'm trying to install numpy on PyCharm 2019.2 but I keep having this error.
I have been told that there are problems in pythons 3.8 and that is why I can't install numpy.
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
failure.
removing: _configtest.c _configtest.obj _configtest.obj.d
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\setup.py", line 444, in <module>
setup_package()
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\setup.py", line 436, in setup_package
setup(**metadata)
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\core.py", line 171, in setup
return old_setup(**new_attr)
File "C:\Users\hp\PycharmProjects\untitled\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\__init__.py", line 145, in setup
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\install.py", line 62, in run
r = self.setuptools_run()
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\build.py", line 47, in run
old_build.run(self)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\build_src.py", line 142, in run
self.build_sources()
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\build_src.py", line 153, in build_sources
self.build_library_sources(*libname_info)
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\build_src.py", line 286, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File "C:\Users\hp\AppData\Local\Temp\pycharm-packaging\numpy\numpy\distutils\command\build_src.py", line 369, in generate_sources
source = func(extension, build_dir)
File "numpy\core\setup.py", line 669, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
Create a new project and virtual environment in PyCharm. Then try downgrading your python to 3.7.2 and uninstall then reinstall numpy through the project settings in pycharm. In your python or bash terminal run,
conda install python == 3.7.2
If you don't have Anaconda Distribution downloaded then navigate to the "Project Interpreter" in PyCharm and you can install/uninstall libraries directly from there with the plus and minus icon. I think you may have a underlying system problem so going for a fresh install of the dependencies you are having issues with should remedy the problem along with stepping away from version 3.8 of Python.
I need the osgeo and GDAL libraries in python code. So, I imported them and I compiled to check whether they are installed or not (I'm not a python expert), and as expected the libraries do not exist. So, I tried to install it using the pycharm setting tools.
For the osgeo, I found two possibilities.
Django-osgeo-importer.
Django-osgeo-importer-client.
and the installation was successful. But for the GDAL I've got an error (see figure).
And I tried also to install the GDAL from the terminal and also I got this error:
anoir#anoir-Lenovo-IdeaPad-Y510P:~$ sudo -H pip install GDAL
Collecting GDAL
Using cached GDAL-2.2.1.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/GDAL.egg-info
writing pip-egg-info/GDAL.egg-info/PKG-INFO
writing top-level names to pip-egg-info/GDAL.egg-info/top_level.txt
writing dependency_links to pip-egg-info/GDAL.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-5IPiZv/GDAL/setup.py", line 339, in <module>
**extra )
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 280, in run
self.find_sources()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 295, in find_sources
mm.run()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 526, in run
self.add_defaults()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 562, in add_defaults
sdist.add_defaults(self)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/py36compat.py", line 36, in add_defaults
self._add_defaults_ext()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/py36compat.py", line 119, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/usr/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/tmp/pip-build-5IPiZv/GDAL/setup.py", line 214, in finalize_options
self.gdaldir = self.get_gdal_config('prefix')
File "/tmp/pip-build-5IPiZv/GDAL/setup.py", line 188, in get_gdal_config
return fetch_config(option)
File "/tmp/pip-build-5IPiZv/GDAL/setup.py", line 141, in fetch_config
raise gdal_config_error, e""")
File "<string>", line 4, in <module>
__main__.gdal_config_error: [Errno 2] No such file or directory
----------------------------------------
Command "python setup.by egg_info" failed with error code 1 in /tmp/pip-build-5IPiZv/GDAL/
So I tried to follow this tutorial Installing GDAL/OGR on Ubuntu and it worked but when I compile the scripts the same problem persists.
Any ideas please?
I have searched on the internet for a solution to import magic correctly in Windows 10 64-bit. I found this, but I do not understand the solution.
It says to copy two DLLs into the specified path in the OS.
What does the below command mean?
file_magic = magic.Magic(magic_file="c:\path\to\magic.mgc")
Is the solution the combination of 1 + 2? Or just 1? I have done 1. Still getting an error. (the 1st error is solved)
>>> import magic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\magic.py", line 176, in <modu
raise ImportError('failed to find libmagic. Check your install
ImportError: failed to find libmagic. Check your installation
Second Error I am getting
>>> import magic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\magic\__init__.py", line 1, in <module>
from . import ffi
File "C:\Python27\lib\site-packages\magic\ffi.py", line 27, in <module>
ext_package="magic")
File "C:\Python27\lib\site-packages\cffi\api.py", line 437, in verify
lib = self.verifier.load_library()
File "C:\Python27\lib\site-packages\cffi\verifier.py", line 113, in load_library
self._compile_module()
File "C:\Python27\lib\site-packages\cffi\verifier.py", line 210, in _compile_module
outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 29, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose)
File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 55, in _build
dist.run_command('build_ext')
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\setuptools\command\build_ext.py", line 75, in run
_build_ext.run(self)
File "C:\Python27\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "C:\Python27\lib\distutils\command\build_ext.py", line 449, in build_extensions
self.build_extension(ext)
File "C:\Python27\lib\site-packages\setuptools\command\build_ext.py", line 196, in build_extension
_build_ext.build_extension(self, ext)
File "C:\Python27\lib\distutils\command\build_ext.py", line 499, in build_extension
depends=ext.depends)
File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python27\lib\site-packages\setuptools\msvc.py", line 136, in msvc9_query_vcvarsall
return EnvironmentInfo(arch, ver).return_env()
File "C:\Python27\lib\site-packages\setuptools\msvc.py", line 1097, in return_env
[self.VCIncludes,
File "C:\Python27\lib\site-packages\setuptools\msvc.py", line 805, in VCIncludes
return [os.path.join(self.si.VCInstallDir, 'Include'),
File "C:\Python27\lib\site-packages\setuptools\msvc.py", line 542, in VCInstallDir
raise distutils.errors.DistutilsPlatformError(msg)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
I think you are successfully completed Step 1. In 2nd step keep your magic.mgc file ( obtained by cloning of libmagicwin64) somewhere accessible by python script ( in the below case C:\Programs\libmagicwin64\ folder). then you can use like this...
>>> import magic
>>> file_magic = magic.Magic(magic_file="C:\Programs\libmagicwin64\magic.mgc")
>>> print(file_magic.from_file("D:\Work Folder\mcabcaaug2016.pdf"))
'PDF document, version 1.4'
I am attempting to make my first .exe file using cx_freeze on 32-bit Ubuntu, but am encountering an unexplained TypeError. I expect I have done something wrong in my setup file, but have yet to find what it might be. Here is the setup script:
import sys
from cx_Freeze import setup, Executable
exe = Executable(
script = 'cornell7.py',
targetName = 'cornell7.exe',
packages = ['header2.py'],
targetDir = 'executable_dir',
includes = [ 'urllib.request', 'socket', 'sys', 'string', 'threading', 'time','datetime'],
copyDependentFiles = True
)
setup( name = 'cornell7.exe',
executables = [exe]
)
(header2.py is a module I myself wrote containing several useful functions)
Here is the command I've been running in the terminal:
python setup.py build
When I enter that command, I get the following error message:
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 14, in <module>
executables = [exe]
File "/usr/lib/pymodules/python2.7/cx_Freeze/dist.py", line 278, in setup
distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/pymodules/python2.7/cx_Freeze/dist.py", line 165, in run
freezer.Freeze()
File "/usr/lib/pymodules/python2.7/cx_Freeze/freezer.py", line 405, in Freeze
self._FreezeExecutable(executable)
File "/usr/lib/pymodules/python2.7/cx_Freeze/freezer.py", line 149, in _FreezeExecutable
scriptModule = finder.IncludeFile(exe.script, exe.moduleName)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 391, in IncludeFile
deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 286, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 353, in _ScanCode
module, relativeImportIndex)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 176, in _ImportModule
deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 246, in _InternalImportModule
parentModule)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 286, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 353, in _ScanCode
module, relativeImportIndex)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 176, in _ImportModule
deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 241, in _InternalImportModule
fp, path, info = self._FindModule(searchName, path)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 84, in _FindModule
for location in path:
TypeError: 'NoneType' object is not iterable
So far as I can tell, I've obeyed the cx_freeze documentation faithfully.
I'm not a cx_freeze expert, but your executable definition looks wrong. The packages argument is supposed to take a list of packages (that is, folders containing __init__.py and zero or more other Python files), not of Python modules (individual .py files).
For more information on the difference between modules and packages, see http://docs.python.org/2/tutorial/modules.html