How to install Scrapy on Mac OS X 10.7 ? (lxml error) - macos

I'm a total newbie concerning Python and I have trouble installing Scrapy on Mac OS X 10.7. I've tried a lot of different things, but in summary, when I run:
scrapy startproject tutorial
I've got these errors :
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Symbol not found: ___xmlStructuredErrorContext
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/lxml/etree.so
After a lot of googling, I've followed this post and tried:
python setup.py build --static-deps --libxml2-version=2.7.8 && pip install lxml
but it tells me:
RuntimeError: ERROR: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available (pass --without-cython to ignore this error).
And if I run the same command with the —without-cython option, I get:
error: command 'llvm-gcc-4.2' failed with exit status 1
(though I've installed XCode command line tools)
Thanks in advance for your help !
(fyi, I am using MacPorts and pip install…)

You mention Macports at the end and also pip. I think you are mixing up packaging and installation methods.
The first import error should not be seen using a macports python as it puts its libraries under /opt/
As you have started on macports I would use the easy way
port install py27-scrapy
This will install all the needed packages (including python and lxml) to get scrapyto work.
To run scrapy you would need to use the macports python in /opt/local/bin/python2.7. This can be set as the default python if /opt/local/bin is on your path and you run port select to choose this as the python found. The scrapy executable script is /opt/local/bin/scrapy-2.7 Version numbers are used because you can have multiple versions of python working at once.

Related

PyMesh problems with Setup on Windows10 and Error using Docker Version

I want to install PyMesh on a Windows 10 PC, if possible it should be installed in the side-packages of an interpreter delivered with the IDE we use.
I tried the way to run the setup discribed here
https://pymesh.readthedocs.io/en/latest/installation.html
so the part :
git clone https://github.com/PyMesh/PyMesh.git
cd PyMesh
git submodule update --init
worked without any problems.
I am not sure on windows if I now just can write
set PYMESH_PATH = path
and if i can use the path "...\PyMesh\PyMesh" here?
so i left out this part
I installed numpy and scipy (allready installed)
and nose because it is mentioned in the requirements.txt.
So my numpy scipy and nose versions are
numpy 1.19.1
scipy 1.6.0
nose 1.3.7 (same as requirenments)
and just run the setup.py with admin rights
python .\setup.py install
which also seemed to work but i got an error trying
python -c "import pymesh; pymesh.test()"
from the PyMesh folder
saying ModuleNotFoundError: No module named 'PyMesh'
or if i go up one Folder doing the same
saying AttributeError: module 'PyMesh' has no attribute 'triangle'
I found this link ImportError: No module named PyMesh
but i just dont know what i should type in there
I tried to install via pip by using pip install pymesh
but pip Installer gives me a different library.
So i tried in the docker version and in docker i tried the pymesh.load_mesh method with an stl File
but got
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
I dont know if this is just the stl format (expecting binary getting ascii or vice versa)
The stl file itself can be opened so shouldnt be corrupted.
So is there a different way to install pymesh? A wheel would be great. Is it possible to install pymesh to the side-packages of a given Interpreter? Did someone else allready had the same error in Docker and knows the issue
thank you for your help

bash: kivy: command not found

I followed the instructions in this link about Kivy installation "Using Homebrew with pip".
However, when I tried to run the code given below:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
It gave me an error:
bash: kivy: command not found
if you installed kivy with pip, you don't need a kivy command, you can use python directly.
python main.py
Because I created a virtual environment to isolate all the things that needs to be installed like kivy, and I installed cython and kivy first before the homebrew, it caused the problem. Even if I use:
python main.py
instead of
kivy main.py
What I did to solve it are the following:
1. Created a new virtual environment
2. Followed the instruction in kivy in right order: (1) homebrew, (2) Cython, then (3) Kivy.
3. Used "python" command instead of "kivy" command because I installed it using pip (refer to the commenr above). For example:
python name_of_your_file.py
Kivy documentation must be confusing that's why.

ImportError: No module named googlemaps

I've installed this package via pip27 on macports. My OS is OSX El Capitan 10.11.6. My python install is 2.7.10.
I'm trying to run an example script that imports googlemaps module, but I keep getting that ImportError. I have a feeling that it's how pip installed it and the reason why python can't find it, but I'm relatively new to pip so I don't know where to start investigating.
I also tried googling for a fix but no dice. Any idea what's happening here?
Here's my code:
import googlemaps # can't import
import argparse
from datetime import datetime
# collect args for lat, long, # of addresses, radius of search
parser = argparse.ArgumentParser(description='Randomize addresses on Google Maps')
parser.add_argument('-lt', '--latitude')
parser.add_argument('-lng', '--longitude')
parser.add_argument('-n', '--count')
parser.add_argument('-r', '--radius')
args = parser.parse_args()
print('Results: ', vars(args))
Error message:
Traceback (most recent call last):
File "randomize_addresses.py", line 1, in <module>
import googlemaps
ImportError: No module named googlemaps
Found a fix. I uninstalled googlemaps via pip and then reinstalled using easy_install. Apparently OSX doesn't like pip.
Looks like you used pre-installed python since you mentioned version 2.7.10 (default version shipped with macOS) which is located at /usr/bin/.
MacPorts installs binaries and libraries under /opt/local. Try to install python via MacPorts and run the program again. Python and pip should both be linked so that packages installed via pip is available to python.
In this case packages installed using pip27 would be available to python27 installed via MacPorts and not /usr/bin/python.
Another way would be to download get-pip.py and install it against /usr/bin/python (pip installation guide).
Note: Make sure you are using python installed via MacPorts. To check this run which python, it should show something like /opt/local/bin/python2.7

OS X 10.8.2 python 3 import sqlite error

Both brew installed python3 and manually compiled python3 with -–enable-loadable-sqlite-extensions fails when import sqlite from python3 shell. Please help!
The module is named sqlite3, not sqlite:
import sqlite3
http://docs.python.org/3/library/sqlite3.html
Update: Now that we've cleared up the module name, the problem being reported:
ImportError: No module named '_sqlite3'
means that your Python instance cannot find the C extension module, _sqlite3.so, that is part of the sqlite3 module in the standard library. Since the file path of the dbapi2.py in the traceback looks reasonable, the issue is probably not a path issue (sys.path). Most likely the _sqlite3 extension module failed to build or link. Check the output from your Python build for errors. OS X 10.8 includes a version of sqlite3 but for security reasons it does not include the optional loadable extensions feature. Your Python build likely included this message:
Failed to build these modules:
_sqlite3
and, earlier, this:
*** WARNING: renaming "_sqlite3" since importing it failed: dlopen(build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
Expected in: flat namespace
in build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
The solution is to build and install a separate copy of sqlite3 that is built with the loadable extensions feature. If you are using Homebrew, its sqlite recipe with the with-functions option should do that. Then rebuild Python.
Homebrew provides python3 with sqlite3 support and loadable modules.
brew install python3 will do the right thing (and brew sqlite, too).
There was a bug, that probably struck you, but it has been fixed

easy_install M2Crypto failing on Windows platform

I am attempting to install M2Crypto on a Windows XP platform. I have Python, easy_install and SWIG installed, but when I attempt to easy_install M2Crypto I get the following:
SWIG\_m2crypto.i(31) : Error: Unable to find 'openssl\opensslv.h'
SWIG\_m2crypto.i(45) : Error: Unable to find 'openssl\safestack.h'
SWIG\_evp.i(12) : Error: Unable to find 'openssl\opensslconf.h'
SWIG\_ec.i(7) : Error: Unable to find 'openssl\opensslconf.h'
error: Setup script exited with error: command 'swig.exe' failed with exit status 1
I have read elsewhere that people have suggested easy_install openssl-devel, but that simply tells me that there are no packages found with that name. Is the name perhaps case-sensitive (I've tried various permutations without success), or does that advice not apply to Windows?
I'm not looking for alternatives to M2Crypto. I am picking up some existing code that uses it, so I need to get my development environment to be able to run what's already written.
As jay stated in his answer you should try to build it from source. And I tried. The setup.py does not recognize the --openssl option. Looking at the output from the default setup.py I realized that the search location was c:\pkg and not c:\pkg\openssl.
The solution:
Download and install OpenSSL from Win32 OpenSSL
Copy the lib and include folders to c:\pkg
Check that swig.exe is available in your path
Run easy_install M2Crypto
Worked for me like a charm.
Had a similar problem. After downloading the source package of M2Crypto and reading the INSTALL file I found the following:
Differences when installing on Windows
--------------------------------------
Before building from source, you need to install OpenSSL's include files,
import libraries and DLLs. By default setup.py assumes that OpenSSL include
files are in ``c:\pkg\openssl\include``, and the import libraries
in ``c:\pkg\openssl\lib``. As with other platforms, you can specify a different
OpenSSL location with --openssl option to build_ext command.

Resources