0

I just bought a new Mac Book Pro with OSX 10.11 El Capitan.

I'm running Google App Engine Launcher python for local dev, which is where I see this in the logs when it reaches import lxml.

"ImportError: No module named lxml"

I followed the instructions from the lxml website

sudo pip install lxml

Package installs but can't be seen on path by python. I updated my path in .bashrc and .bash_profile with:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/lib/python2.7/site-packages/:$PATH

Then found this article Installing lxml on Mac OSX (10.11) inside a virtualenv with pip

$ STATIC_DEPS=true pip install lxml

Again it installs but can't be found.

I even tried compiling from source and installing macports as it got it embedded, but still no luck.

I read the lxml team is frustrated with OSX and the mess with its outdated libraries and all.

UPDATE

In relation to the comments made, its not a app.yaml libraries declaration, and its unlikely an issue specific to GAE, as it seems more likely between python and oxs-elcapitan.

also I get this unusual message

The directory '/Users/[username]/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.

I tried with sudo -H but that didn't resolve the paths either.

But it does suggest the changes in 10.11 might be part of the problem.

user3225920
  • 59
  • 1
  • 5
  • Did you run `source ~/.bash_profile` to load the updated path? – Forge Mar 07 '16 at 15:39
  • Possible duplicate of [ImportError: No Module named simplejson](http://stackoverflow.com/questions/2604841/importerror-no-module-named-simplejson) –  Mar 07 '16 at 15:48
  • 1
    What does this have to do with appengine? – Tim Mar 07 '16 at 15:52
  • This line hints that it can be related to GAE specifically: "I'm **running _Google_App_Engine_Launcher_** python for local dev, **which is where** I see this in the logs when it reaches import lxml." – Alexander Trakhimenok Mar 07 '16 at 17:49
  • Yes, ran ` source ` to update the PATH, restarted the machine also. Still no luck. Also ran GAE to reset it's symlinks. I don't think its specifically a problem with GAE, and it seem more like a fundamental path problem between python and osx 10.11 – user3225920 Mar 07 '16 at 21:39
  • I am having the same problem with lxml and appengine. Numpy and other libraries in my app.yaml work fine. Did you find a fix? – Badger Cat Mar 12 '16 at 19:39
  • Cf https://stackoverflow.com/questions/19548011/cannot-install-lxml-on-mac-os-x-10-9 – Nemo Jan 30 '18 at 16:18

2 Answers2

0

AppEngine uses it's own environment that reflects their server and does not see libraries that you've installed locally.

To see the package it should be located in the root of the project (where the app.yaml is located).

But there is also runtime provide libraries- read section "Using Runtime-Provided Libraries with the Local Development Server" at https://cloud.google.com/appengine/docs/python/tools/libraries27

Probably you would need to add to app.yaml:

libraries:
- name: lxml
  version: "2.3.5"
Alexander Trakhimenok
  • 6,019
  • 2
  • 27
  • 52
  • Some Python libraries (e.g. lxml) are platform-dependent and must be installed locally before you can use them with the development server. – pgiecek Mar 07 '16 at 15:57
  • Right, but that does not mean you should not modify the app.yaml to allow the appengine to see/use them. – Alexander Trakhimenok Mar 07 '16 at 15:58
  • He should definitely declare the library in app.yaml but if I get it right, he is not able to install the library on his computer. – pgiecek Mar 07 '16 at 16:01
  • This line hints that it can be related to GAE specifically: "I'm **running _Google_App_Engine_Launcher_** python for local dev, **which is where** I see this in the logs when it reaches import lxml." – Alexander Trakhimenok Mar 07 '16 at 17:49
  • It's not the libraries in the app.yaml. Specifically I have several declared. libraries: - name: lxml version: latest - name: pycrypto version: latest - name: webapp2 version: latest - name: jinja2 version: latest – user3225920 Mar 07 '16 at 21:28
0

STATIC_DEPS didn't work for me (looks like the relevant FTP sites were down?), but this did the trick:

C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2:$C_INCLUDE_PATH pip install lxml