Missing multiprocessing module when freezing Python code - python

I'm using cx_Freeze to freeze my Python code so I can distribute it as executable on Windows systems. It works fine but it's missing a few modules. I use some open-source libraries in my project e.g. BeautifulSoup and Periscope. They use some libraries for backward compatibility which i don't need to include as Python 2.6 has them. The problem is the third import — multiprocessing._multiprocessing. Can anyone tell me what I need to install in order to fix this? The mutiprocessing module seems to come bundled with Python so what's causing this error?
Missing modules:
? cjkcodecs.aliases imported from BeautifulSoup.BeautifulSoup
? iconv_codec imported from BeautifulSoup.BeautifulSoup
? multiprocessing._multiprocessing imported from multiprocessing.forking
? xdg.BaseDirectory imported from periscope.periscope
Any help?
Thanks guys!

There was a similar issue on Google App Engine. See this
I fixed this my putting a _multiprocessing.py file into the multiprocessing module's folder. This file contained the code:
import multiprocessing
This works but it isn't a robust answer.

Related

How to import .Net Classes in Python using Python.Net

I'm using Python.NET to create wrapper for iText.net (https://github.com/itext/itext7-dotnet).
The dll is named itext.kernel.dll and the python script is in the samne folder of all the itext dlls.
With Jetbrain dotPeek I see that itext.kernel has various namespaces; the namespace iText.Kernel.Pdf is what I need, in particular the public class PdfReader.
Here's what I'm doing (from the docs on https://pythonnet.github.io/):
import clr
clr.AddReference('itext.kernel')
sys.path.append(os.getcwd()) # the script is currently in the dll folder
from iText.Kernel.Pdf import PdfReader
But this gets me a "ModuleNotFoundError: No module named 'iText'" error.
I can't understand what it's wrong, can someone point me to the right direction? Thanks.
edit: I can import and use iTextSharp just fine, it seems iText7 has something different.
Well, long story short I really wanted this to work... and solved my issue!
I tried using older builds, and I found out that build 7.0.8 worked fine.
I compared it with build 7.1.11 (the one I was having problems with) using dotPeek, and noticed it has some references, namely BouncyCastle.Crypto, Common.Logging and Common.Logging.Core.
I did put them in the project folder, but still no dice... until I noticed I was using BouncyCastle.Crypto build 1.8.6, while the itext.kernel referred build 1.8.5! Replacing with that version solved the issue.
Basically the newer builds of iText7 have 3 referenced libs, that must be present in the exact same version (at least to be imoported by pythonnet).
I hope this can help someone that has issues similar to mine.

Python not able to import any module

I don't know whether I've just installed them wrong or there's another problem. I installed the ebay sdk but whenever I try to import it I get
ModuleNotFoundError: No module named 'ebaysdk'
Are there any common problems with this I could check for a solution? It shouldn't be the code as I copied it from the example code off the website.
Thanks for any help.
P.S I'm using 3.6

Is it possible to specify the search path for a module in a python script? If it is, how do I do that?

I have been coding in python for about 2 months, but I'm only familiar with basic object-oriented programming, so I do not really understand things like how searching for modules is implemented. (Basically I'm a noob.)
I pip installed a package called Opentrons Opentrons 2.5.2 and all its dependencies into the samefolder as a python script I'm currently writing. However when I tried to import the module below[1], I get an error saying that "Opentrons is not a module". Then, I tried shifting it into the python library because I found out the search path using the pprint module and it seems to work. I was wondering if I can specify the search path from the .py file itself instead of manually printing the search path and putting the file into the library that the script searches for. (Willing to put in images of the directories I put the opentrons package in if it helps.)
[1]
import sys
import pprint
pprint.pprint(search.path)
from opentrons import robot, containers, instruments
Edit: I realise that the fact that I am running all my scripts in a Spyder console located in a python 3.6 environment might be important.
You can try using the __import__ function, or importlib. This should allow you to specify the path.

Importing modules from relative path to absolute

I am trying to run a program which it specification say for python 2.6 I am running it with python 2.6.6, so it should work but I found that the importation fails see this question, and this sample:
from rnaspace.dao.storage_configuration_reader import storage_configuration_reader
This is due to a version change (I doubt) or of some of the environment on the original server? A solution is in the question cited, but I there is another way to solve this problem that it doesn't involve to change each file with this kind of importation?
Your import statement assumes python knows where the 'rnaspace' package is. Maybe you need to add the path to the package rnaspace in your include path?
import sys
pathToRnaspace = "/path/to/the/rnaspace/package"
sys.path.append(pathToRnaspace)
from rnaspace.core.putative_rna import putative_rna

Python: import graphutil module

I am modifying an old python code which imports graphutil module. However I am unable to find the source-package for the module and install it on ubuntu. Any help in this direction will be appreciated.
I doubt this is it, but there was a file in pywafo that may have been lifted for your project. This is the best I can find.

Categories