Installing mesos egg for python 2.7 - python

I've installed mesos 0.26 successfully on a vm machine.
The installation has been performed on an ubuntu trusty thar system
by following this manual:
https://open.mesosphere.com/getting-started/install/
So far so good. I wanted to write a tiny python framwork.
For this I need to install the eggs via easy_install:
(I've downloaded the eggs accordingly for the trusty thar ubuntu and the 0.26 mesos):
wget http://downloads.mesosphere.io/master/ubuntu/14.04/mesos-0.26.0-py2.7-linux-x86_64.egg
easy_install mesos-0.26.0-py2.7-linux-x86_64.egg
all went fine, however, if I start python in the shell
and type in
import mesos.interface
I get the message: ImportError: No module named interface
As someone suggested, it may be that there is no longer a binding for python, or that they have renamed the API calls. Well, I looked in the version updates here:
http://mesos.apache.org/documentation/latest/upgrades/
Since the transition from 0.19.x to 0.20.x there hasn't been any changes regarding the mesos.interface part, or at least they are not mentioning it here.
To increase the confusion I also get the following error message when I'm typing in python: import mesos.native
There I receive: ImportError: No module named interface.mesos_pb2. To put it into a nutshell: what is going wrong here, and how can it be fixed? And yes, I've googled various web pages, with terms such as "mesos python bindings", mesos +api +python, etc. And yes, I have also consulted the official mesos webpage. There are nice refences for Java and C++ but not for python, or at least they are very well hidden.
Thanks in advance for any hints.

Solved. For what reasons ever:
export PYTHONPATH=${PYTHONPATH}:/usr/lib/python2.7/site-packages/
is required to set the PYTHONPATH. After that step it works like a charm.

Related

RDKit installation under Windows and Python3.7.4

RDKit could be a nice package if it wasn't so complicated to install.
Here on SO, there are several questions having problems with the installation of RDKit.
However, on different operating systems or different environments.
My configuration is:
Win10, Python 3.7.4, pip is installed, PATH is set, PYTHONPATH is set.
The installation of other modules is working fine via python -m pip install <package>.
I'm aware that the site recommends the fastest installation with Anaconda.
However, I don't have and don't want Anaconda.
On the webpage it says:
"Get the appropriate windows binary build from: https://github.com/rdkit/rdkit/releases".
However, there are no binaries of the latest versions.
This means, I would have to build it from source. I'm hesitating because the process seems to be pretty complicated, many extra installations with new problems and unknowns, and furthermore, the instructions seem to be outdated and incomplete for somebody who would build binaries from the source for the first time.
So, then I tried some unofficial binaries of RDKit.
If I unpack them and set the paths according to instructions, I get this error message:
>>> from rdkit import Chem
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\xyz\Programs\RDKit\rdkit\__init__.py", line 2, in <module>
from .rdBase import rdkitVersion as __version__
ImportError: DLL load failed: The specified module could not be found.
So, finally my questions:
How to properly install RDKit with the above mentioned configuration?
What is the specified DLL which is missing?
Where is it expecting it and searching it?
Are these RDKit 3.6 binaries maybe incompatible with Python 3.7.4?
I'm pretty sure it is probably a "small" thing (a path here or a check there), but I'm stuck. Thank you for any hints.
Update:
Apparently, it is not just a "small" thing. Chances to get this to work are most likely very low.
In the meantime I found this:
https://github.com/rdkit/rdkit/issues/1812
https://github.com/rdkit/rdkit/issues/2389
If the author of rdkit writes (April 2019):
I would be happy to be able to do pip distributions of the RDKit, but
to the best of my knowledge no one has managed to figure out how to
make it actually work.
I'd be happy to accept a PR from someone who has figured this out, but
I am not likely to have the time to do this myself anytime in the near
future.
So, if anybody feels capable achieving this, please feel free.
I will invest time in something else or will have to switch to Anaconda if I want to use RDKit.
On the webpage you linked there is a section about missing DLLs:
"In Win7 systems, you may run into trouble due to missing DLLs, see one thread from the mailing list: http://www.mail-archive.com/rdkit-discuss#lists.sourceforge.net/msg01632.html You can download the missing DLLs from here: http://www.microsoft.com/en-us/download/details.aspx?id=5555"
Not sure if this helps

ImportError: No module named 'resource'

I am using python 3.5 and I am doing Algorithms specialization courses on Coursera. Professor teaching this course posted a program which can help us to know the time and memory associated with running a program. It has import resource command at the top. I tried to run this program along with the programs I have written in python and every time I received ImportError: No module named 'resource'
I used the same code in ubuntu and have no errors at all.
I followed suggestions in stackoverflow answers and I have tried adding PYTHONPATH PYTHONHOME and edited the PATH environment variable.
I have no idea of what else I can do here.
Is there any file that I can download and install it in the Lib or site-packages folder of my python installation ?
resource is a Unix specific package as seen in https://docs.python.org/2/library/resource.html which is why it worked for you in Ubuntu, but raised an error when trying to use it in Windows.
I ran into similar error in window 10. Here is what solved it for me.
Downgrade to the Apache Spark 2.3.2 prebuild version
Install (or downgrade) jdk to version 1.8.0
My installed jdk was 1.9.0, which doesn't seem to be compatiable with spark 2.3.2 or 2.4.0
make sure that when you run java -version in cmd (command prompt), it show java version 8. If you are seeing version 9, you will need to change your system ENV PATH to ensure it points to java version 8.
Check this link to get help on changing the PATH if you have multiple java version installed.
Hope this helps someone, I was stuck on this issue for almost a week before finally finding a solution.

Python 2.7.5 on Cygwin64: requests installation fails

Our project is a mostly J2EE based development with the automatic functional and integration tests written in Python. The test environment is Linux nonetheless developers use Windows 7 (64-bit). We would like to be able to execute the functional tests on the developer machines as well (before comitting). Unfortunately the pexpect-windows-portability issue would leave us no choice but:
To do some serious refactoring on our test libraries to be able to use both winpexpect (or wexpect) and pexpect depending on the os settings.
Or to use cygwin. Guess what, with this second option we seem to have an issue :-) Using Python 2.7.5 on Cygwin64 installing the requests package results in error:
pip says it can not find a file after downloading and extracting the library
easy install doesn't throw an explicit error, but leaves everything in the temporary dir
after copying the files under the site-packages directory a simple import requests in python causes the interpreter to exit
Has anybody encountered this problem? With Cygwin-32 requests install smoothly. (however we have some other issues - see my next post ;-))
Thank you in advance: Joe, the public
Also ran into the same issues when trying to install requests, all the options on http://docs.python-requests.org/en/latest/user/install/#install did not work. I went to https://github.com/kennethreitz/requests and then clicked on "Download Zip" and I got requests-master.zip.
Update: This should be fixed in Cygwin.
This was a bug in CPython that has been fixed in their master branch. I've pushed a candidate package to the Python maintainer for Cygwin, but you might try this hotfix.
I downloaded from "https://github.com/requests/requests" and then i just ran the setup.py from the requests-master folder ( this was placed in cygwin folder). After that I went to cygwin terminal and then I ran python --> import requests. Voila it worked.

Is it possible to write a windows service using Python?

Python has a win32service package that seems to allow windows service creation. I have carefully checked available google examples, for example this one:
Is it possible to run a Python script as a service in Windows? If possible, how?
I have placed code into ~/Documents/test.py and executed following under elevated command prompt:
> python test.py install
> python test.py debug
Unfortunately, every example i tried fails with error:
Debugging service TestService - press Ctrl+C to stop.
Error 0xC0000005 - Python could find the service class in the module
AttributeError: 'module' object has no attribute 'AppServerSvc'
(null): (null)
I have tested it with latest version of ActivePython (2.7.2.5 32-bit) on Windows 7 64-bit and Windows 8 64-bit. Of course, if service is started maually via service manager, it will not start either.
Am i doing something wrong or Python is not intended to be used for service creation on modern operating systems? Maybe i need a specific version of windows/python/pywin32? Of course, i can manually test all combinations starting from windows XP but it will take lots of time :(. Maybe someone already has experience with Python and windows services and can hint me what i'm doing wrong?
update
Tested on Windows XP 32-bit virtual macine (same code, same activepython distribution) - same error.
It appears that there is a bug in the ActiveState build for PyWin32. Installing ActiveState python 2.7.2.5 and running the linked sample code above, I get the same error that you are reporting.
But if I download Python 2.7.3 (2.7.2.5 does not seem to be available for download) and add PyWin32 build 214 (ActiveState seems to be using the 214 version of PyWin32). Then everything seems to work just fine. I also tried the latest build of PyWin32 (218) and it also worked correctly.
So I guess you can try reporting the problem to ActiveState (I don't have a support contract with them) and unless you have a requirement for using ActiveState, you can just switch to the standard Python builds.
I have been using services with the standard Python builds for years running on everything from Windows 2000 up to Server 2008 and Windows 7 with no problems. So I have good reason to believe that it will work for you also.
If you want to work with ActiveState to get the problem fixed, then the bug appears to be in their build of PythonService.cpp in the LoadPythonServiceInstance function. I looked at the registry entries that were created and they look fine, it is the PythonService.exe that is failing at loading your class. Based on the error message it appears to have loaded the module correctly and is just having trouble finding the class.

How do I find out what Python libraries are installed on my Mac?

I'm just starting out with Python, and have found out that I can import various libraries. How do I find out what libraries exist on my Mac that I can import? How do I find out what functions they include?
I seem to remember using some web server type thing to browse through local help files, but I may have imagined that!
From the Python REPL (the command-line interpreter / Read-Eval-Print-Loop), type help("modules") to see a list of all your available libs.
Then to see functions within a module, do help("posix"), for example. If you haven't imported the library yet, you have to put quotes around the library's name.
For the web server, you can run the pydoc module that is included in the python distribution as a script:
python /path/to/pydoc.py -p 1234
where 1234 is the port you want the server to run at. You can then visit http://localhost:1234/ and browse the documentation.
Every standard python distribution has these libraries, which cover most of what you will need in a project.
In case you need to find out if a library exists at runtime, you do it like this
try:
import ObscureModule
except ImportError:
print "you need to install ObscureModule"
sys.exit(1) # or something like that
You can install another library: yolk.
yolk is a python package manager and will show you everything you have added via pypi. But it will also show you site-packages added through whatever local package manager you run.
just run the Python interpeter and type the command
import "lib_name"
if it gives an error, you don't have the lib installed...else you are good to go
On Leopard, depending on the python package you're using and the version number, the modules can be found in /Library/Python:
/Library/Python/2.5/site-packages
or in /Library/Frameworks
/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/site-packages
(it could also be 3.0 or whatever version)...
I guess it is quite the same with Tiger
Considering that in every operating system most of python's packages are installed using 'pip' (see pip documentation) you can also use the command 'pip freeze' on a terminal to print a list of all the packages you have installed through it.
Other tools like 'homebrew' for macOS (used when for some reason you can't install a package using pip) have similar commands, in this specific case 'brew list'.

Categories

Resources