简体   繁体   中英

ModuleNotFoundError in Anaconda3 when installing package with pip

I'm running conda 4.4.8 on mac OS 10.11.16 and I'm trying to properly install a third-party package that I have as a tar.gz file. The package installation seems to work without any issue (having already tried to install, this in what I get when I run it again):

$: pip install ~/Downloads/pydelay-0.1.1.tar.gz

Processing ~/Downloads/pydelay-0.1.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pydelay==0.1.1 from file://~/Downloads/pydelay-0.1.1.tar.gz in ~/anaconda3/lib/python3.6/site-packages
Building wheels for collected packages: pydelay
Running setup.py bdist_wheel for pydelay ... done
Stored in directory: ~/Library/Caches/pip/wheels/5d/b7/4e/3896677f80cccebfc2d300904aca54ebbd6b0885cb9440e13d
Successfully built pydelay

Then I do a check to make sure there aren't dependencies missing:

$: pip check pydelay

No broken requirements found.

However, when I run my piece of code that uses the package, I get the following error:

runfile('~/.../DDEin3+1D.py', wdir='~/...')
Traceback (most recent call last):

File "ipython-input-16-12e8207a0dca", line 1, in runfile('~/.../DDEin3+1D.py', wdir='~/...')

File "~/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 710, in runfile execfile(filename, namespace)

File "~/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 101, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "~/.../DDEin3+1D.py", line 18, in
from pydelay import dde23

File "~/anaconda3/lib/python3.6/site-packages/pydelay/__init__.py", line 9, in
from _dde23 import dde23

ModuleNotFoundError : No module named '_dde23'

I don't think its a version problem, but because the pydelay package is from 2009 it very well could be.

Any help with getting the spyder editor (or command line python) to find this package would be greatly appreciated!

Just in case anyone runs into something like this, I thought I would post the solution. In this instance, the __init__.py file was searching my default PATH for _dde23, which was actually located in the same directory as __init__.py. The solution was simply to change the import call in __init__.py to

from ._dde23 import dde23

This told the file to look within the same directory for the module. I found similar problems throughout the package, and with this small change solved them all. I'm not an expert, but it might have been something to do with pydelay being built with python2.x while I was running python3.x.

Of course, getting other parts of this module to work with depreciated dependencies is another matter ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM