0

I see when pycurl is installed but when I run a script which has pycurl it throws the error ImportError: No module named pycurl

pycurl installed

 users-iMac:clone_radar user$ sudo pip install pycurl
    The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    Requirement already satisfied: pycurl in /Users/user/Library/Python/2.7/lib/python/site-packages

Error:-

users-iMac:clone_radar user$ python ./cloneradar.py username 4364_test radar.py
Traceback (most recent call last):
  File "./cloneradar.py", line 7, in <module>
    from RadarWS import RadarWS
  File "/Users/user/Documents/cloning_radar/com/clone_radar/RadarWS.py", line 28, in <module>
    import pycurl
ImportError: No module named pycurl

if I try to install without sudo I get the error

Command "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/fh/1g80t0p942bf8_pnjjl8r21m0000gn/T/pip-build-QmeyZh/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/fh/1g80t0p942bf8_pnjjl8r21m0000gn/T/pip-4p7wF2-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/fh/1g80t0p942bf8_pnjjl8r21m0000gn/T/pip-build-QmeyZh/pycurl
wisecrack
  • 315
  • 2
  • 12
  • 1
    Did you try the suggested solutions on this SO question? https://stackoverflow.com/questions/28958563/how-to-resolve-importerror-no-module-named-pycurl – pastaleg Jan 12 '18 at 23:02
  • Can you try running this from that script: `import sys; print sys.path`. Does it contain `/User/user/Library/Python/2.7/lib/python/site-packages`? – pushkin Jan 12 '18 at 23:03
  • 1
    You installed the package with `sudo`. Probably your web application has no access to the superuser's library. – masterfloda Jan 12 '18 at 23:09
  • @Magnus - I tried what you suggested ,I still get the same error – wisecrack Jan 12 '18 at 23:43
  • @pushkin - it has `/Library/Python/2.7/site-packages` – wisecrack Jan 12 '18 at 23:46
  • @masterfloda - I updated the question with the error I get if I try to install without sudo – wisecrack Jan 12 '18 at 23:49
  • @user3682248 Ok, so it looks like it's looking in a different directory. It's possible that `sudo` installs stuff in a different directory. Your `pycurl` is in `/Users/user/Library/Python/2.7/lib/python/site-packages`, but `import` is looking in `/Library/Python/2.7/site-packages`. This shouldn't go into production, but as a quick workaround, you can do `sys.path.append('/Library/Python/2.7/lib/python/site-packages')`. Long-term, we'll need to figure out why it got installed to a different place. – pushkin Jan 12 '18 at 23:52
  • @pushkin - is there a way to force pip to install in the specific directory it is looking for? – wisecrack Jan 13 '18 at 00:13
  • 1
    I recommend using a virtual environment: https://virtualenv.pypa.io/en/stable/ – masterfloda Jan 13 '18 at 00:13
  • @user3682248 [This](https://stackoverflow.com/questions/29980798/where-does-pip-install-its-packages) may help. You might try installing using `easy_install` also – pushkin Jan 13 '18 at 00:20

0 Answers0