2

I have a Windows 7 64bit machine and want to install the python package mgrs. I have tried using both easy_install and running python setup.py install in the mgrs directory. Easy_install gives me the error below.

C:\Users\farrell>easy_install mgrs
Searching for mgrs
Reading https://pypi.python.org/simple/mgrs/
Best match: mgrs 1.1.0
Downloading https://pypi.python.org/packages/source/m/mgrs/mgrs-1.1.0.tar.gz#md5
=96e0c00f16d86a3f8b84c2c46cb68b8e
Processing mgrs-1.1.0.tar.gz
Writing c:\users\farrell\appdata\local\temp\easy_install-lzqjsi\mgrs-1.1.0\setup
.cfg
Running mgrs-1.1.0\setup.py -q bdist_egg --dist-dir c:\users\farrell\appdata\loc
al\temp\easy_install-lzqjsi\mgrs-1.1.0\egg-dist-tmp-sxkdib
Traceback (most recent call last):
  File "C:\Python27\Anaconda\Scripts\easy_install-script.py", line 9, in <module
>
    load_entry_point('setuptools==5.4.1', 'console_scripts', 'easy_install')()
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 2147
, in main
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 2133
, in with_ei_usage
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 2150
, in <lambda>
  File "C:\Python27\Anaconda\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\Anaconda\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\Anaconda\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 370,
 in run
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 613,
 in easy_install
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 643,
 in install_item
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 833,
 in install_eggs
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1055
, in build_and_install
  File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1040
, in run_setup
  File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 63, in run_setup
  File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 109, in run
  File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 62, in runner
  File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 38, in _execfile
  File "c:\users\farrell\appdata\local\temp\easy_install-lzqjsi\mgrs-1.1.0\setup
.py", line 8, in <module>
ImportError: cannot import name Library

line 8 of setup.py is from setuptools import Library as Extension

Any help on what is causing the problem?

brendan8229
  • 47
  • 1
  • 2
  • 9
  • I bet there's no `Library` in your `setuptools` module. Might be an old version or something. My `distribute-0.6.35` has it. – ivan_pozdeev Jul 08 '14 at 14:00

2 Answers2

3

In old versions of setuptools, the Library class was imported into the setuptools package. This hasn't been the case since version 1.1.

That setup.py script is written against an older version of setuptools than you have installed.

You should be able to fix it by editing setup.py and changing the import to:

from setuptools.extension import Library

Post installation

For this particular package in Windows it seems to install the built DLL to the site-packages directory. Once installed, edit mgrs\core.py and replace the line:

local_dlls = os.path.abspath(os.__file__ + "../../../DLLs")

With:

import site
local_dlls = ";".join(site.getsitepackages())
Jamie Cockburn
  • 7,379
  • 1
  • 24
  • 37
  • I made the change you suggested and the installation seems to have gone through. But when I open ipython, for example and try to import mgrs I am told there is no such module. Any further thoughts? Perhaps that I have this anaconda package? Below is the installation message I got. Installed c:\python27\anaconda\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg Processing dependencies for mgrs==1.1.0 Searching for setuptools==5.4.1 Best match: setuptools 5.4.1 Processing setuptools-5.4.1-py2.7.egg – brendan8229 Jul 07 '14 at 19:06
  • Thanks a lot. I made this change as well but still get the error below. File "", line 1, in File "C:\Python27\Anaconda\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg\mgrs\__init__.py", line 1, in from core import rt File "C:\Python27\Anaconda\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg\mgrs\core.py", line 22, in rt = ctypes.PyDLL(lib_name) File "C:\Python27\Anaconda\lib\ctypes\__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 126] The specified module could not be found – brendan8229 Jul 08 '14 at 13:44
  • Edit `core.py` and add print statements to see what the values of `local_dlls` is. Then check that 'libmgrs.dll' exists at one of those paths. If not, find out where it is, and change `local_dlls` to equal that path instead. – Jamie Cockburn Jul 08 '14 at 13:59
  • I've followed user and Jamie's steps error-for-error, but I have an additional error after sorting out the DLL: 'OSError: [WinError 193] %1 is not a valid Win32 application' I'm guessing this is due to a C compilation error, but am unsure how to fix it. – Turtles Are Cute Feb 08 '15 at 22:07
  • @TurtlesAreCute You'll need to post the full stack trace you're getting. I'd recommend creating a new question, but make sure you detail that you are working with a hacked version of the library. – Jamie Cockburn Feb 09 '15 at 09:39
0

Check and make sure you have the latest version of SetupTools installed. Previous posts about this issue were linked to having a screwy version of SetupTools on the machine. Also, you might want to try pip instead of easy_install as it's a bit better.

Community
  • 1
  • 1
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88