I maintain an experimental tool that still python 2.7 that use a bunch of libraries, such as Gdal, shapely, astropy, OpenCV2, scipy, etc. Everything was fine until the system as changed, so virtual environment has been redone and then I have a problem with multiprocessing function.
The most simplified code to reproduce the behaviour:
import multiprocessing
if __name__ == '__main__':
cpus = multiprocessing.cpu_count()
cpus = cpus - 1
pool = multiprocessing.Pool(processes=cpus)
Result #1 with:
Python : VirEnv 2.7 build
Console : Pycharm PyDev console
Traceback (most recent call last): File "", line 1, in
Traceback (most recent call last): File "", line 1,
in File "C:\Python27\Lib\multiprocessing\forking.py", line
380, in main
prepare(preparation_data) File "C:\Python27\Lib\multiprocessing\forking.py", line 504, in prepare
File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
file, path_name, etc = imp.find_module(main_name, dirs) ImportError: No module named input
prepare(preparation_data) File "C:\Python27\Lib\multiprocessing\forking.py", line 504, in prepare
file, path_name, etc = imp.find_module(main_name, dirs) ImportError: No module named input
Why it is looking into "C:\Python27\Lib\multiprocessing\" instead of the VirEnv 2.7 build?
Result #2 with:
Python : VirEnv 2.7 from Anaconda
Console : Pycharm PyDev console
Traceback (most recent call last): File "", line 1, in
File
"C:\Users\_____\AppData\Local\conda\conda\envs\Python_27\lib\multiprocessing\spawn.py",
line 105, in spawn_main
exitcode = _main(fd) File "C:\Users\_____\AppData\Local\conda\conda\envs\Python_27\lib\multiprocessing\spawn.py",
line 114, in _main
prepare(preparation_data) File "C:\Users\_____\AppData\Local\conda\conda\envs\Python_27\lib\multiprocessing\spawn.py",
line 225, in prepare
_fixup_main_from_path(data['init_main_from_path']) File "C:\Users\_____\AppData\Local\conda\conda\envs\Python_27\lib\multiprocessing\spawn.py",
line 277, in _fixup_main_from_path
run_name="mp_main") File "C:\Users\_____\AppData\Local\conda\conda\envs\Python_27\lib\runpy.py",
line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name) File "C:\Users\_____\AppData\Local\conda\conda\envs\Python_27\lib\runpy.py",
line 231, in _get_code_from_file
with open(fname, "rb") as f: OSError: [Errno 22] Invalid argument: 'B:\WorkingSpace\_____\API\'
Result #3 with:
Python : VirEnv 2.7 build
Console : Pycharm terminal
Passed without error
Result #4 with:
Python : VirEnv 2.7 from Anaconda
Console : Pycharm terminal
Passed without error
Result #5 with:
Python : VirEnv 2.7 from Anaconda
Console : Anaconda terminal
Passed without error
So, Pycharm PyDev console seems where only the crash occurs? Why? How to get rid of this?
In addition :
After the console initialization, I have:
B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev\pydevconsole.py" --mode=client --port=_____
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['B:\\WorkingSpace\\_____\\API', 'B:/WorkingSpace/_____/API'])
PyDev console: starting.
Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32
When I pass the simplified code to reproduce the behaviour, the error "ImportError: No module named " occur in the forking.py which is in the path "C:\Python27\Lib\multiprocessing\".
Sys.path are:
'C:\Program Files\JetBrains\PyCharm Community Edition
2019.2\helpers\pydev',
'C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\third_party\thriftpy',
'C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev',
'C:\Windows\SYSTEM32\python27.zip',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\DLLs',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\lib',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\lib\plat-win',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\lib\lib-tk',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\Scripts',
'C:\Python27\Lib',
'C:\Python27\DLLs',
'C:\Python27\Lib\lib-tk',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7',
'B:\WorkingSpace\_____\API\virEnv_Desktop_V2.7\lib\site-packages',
'B:\WorkingSpace\_____\API',
'B:/WorkingSpace/_____/API'
What happening?
Related
I want to work with nfcpy on Windows 7.
Thus, I followed the instructions from https://nfcpy.readthedocs.io/en/latest/topics/get-started.html#installation
When I execute python-m nfc, I have the following error:
$ python -m nfc
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 163, in run_module_as_main
mod_name, Error)
File "C:\Python27\lib\runpy.py", line 111, in get_module_details
import(mod_name) # Do not catch exceptions initializing package
File "C:\Python27\lib\site-packages\nfc_init.py", line 22, in
from . import clf # noqa: F401
File "C:\Python27\lib\site-packages\nfc\clf_init.py", line 25, in
from . import device
File "C:\Python27\lib\site-packages\nfc\clf\device.py", line 32, in
from . import transport
File "C:\Python27\lib\site-packages\nfc\clf\transport.py", line 31, in
import usb1 as libusb
File "C:\Python27\lib\site-packages\usb1_init.py", line 61, in
from . import libusb1
File "C:\Python27\lib\site-packages\usb1\libusb1.py", line 199, in
libusb = _loadLibrary()
File "C:\Python27\lib\site-packages\usb1\libusb1.py", line 173, in loadLibrary
return dll_loader('libusb-1.0' + suffix, **loader_kw)
File "C:\Python27\lib\ctypes_init.py", line 366, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
I tried with 2 different python 2.7 installer version:
-> Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [**MSC v.1500 64 bit (AMD64)**] on win32
-> Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [**MSC v.1500 32 bit (Intel)**] on win32
I have the same error with both.
Copy MS32\dll\libusb-1.0.dll to C:\Windows\SysWOW64 directory.
I have installed ghostscript on my machine and is located at
C:\Program Files (x86)\gs\gs9.20
and installed the python module via pip
pip install ghostscript
however when I try and import ghostscript I get this error
>>> import ghostscript
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import ghostscript
File "C:\Python27\lib\site-packages\ghostscript\__init__.py", line 33, in <module>
import _gsprint as gs
File "C:\Python27\lib\site-packages\ghostscript\_gsprint.py", line 281, in <module>
libgs = windll.LoadLibrary(libgs)
File "C:\Python27\lib\ctypes\__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be string, not Unicode
Ghost script was not working in python v2.7.13 so running an installation of v2.7.12 and importing via v2.7.12 imports with no errors
I am trying to package a kivy application for Windows, and after following the instructions in the Kivy website for the example TouchTracer app, I get an ImportError: No Module named ConfigParser message when trying to open the .exe file in the dist folder.
I am running Python 2.7.11 and kivy 1.9.1.
Also, while executing the command python -m PyInstaller..., the output includes a line that says:
12612 WARNING: Attempted to add Python module twice with different upper/lowercases: ConfigParser
Below is the traceback printed when attempting to open the .exe file.
Traceback (most recent call last):
File "C:\Users\acasall1\Desktop\TouchApp\demo\touchtracer\main.py", line 22,
in <module>
import kivy
File "c:\users\acasall1\appdata\local\temp\pip-build-21skkd\pyinstaller\PyIns
taller\loader\pyimod03_importers.py", line 389, in load_module
File "c:\python27\lib\site-packages\kivy\__init__.py", line 306, in <module>
from kivy.config import Config
File "c:\users\acasall1\appdata\local\temp\pip-build-21skkd\pyinstaller\PyIns
taller\loader\pyimod03_importers.py", line 389, in load_module
File "c:\python27\lib\site-packages\kivy\config.py", line 284, in <module>
from configparser import RawConfigParser as PythonConfigParser
File "c:\users\acasall1\appdata\local\temp\pip-build-21skkd\pyinstaller\PyIns
taller\loader\pyimod03_importers.py", line 389, in load_module
File "C:\Python27\lib\site-packages\configparser\__init__.py", line 5, in <mo
dule>
from ConfigParser import *
ImportError: No module named ConfigParser
Failed to execute script main
I had the same problem for my kivy application, and I found an ad hoc solution. The error comes from the line "import kivy", so uncomment it and the next line "kivy.require('1.0.6')". There lines are unnecessary if your kivy has proper version.
System:
Windows 7 64-bit
Anaconda 2.7 64-bit
py2exe 64-bit
Background:
I converted my python code to .exe using py2exe and setup.py file shown below:
from distutils.core import setup
import py2exe
from distutils.filelist import findall
import matplotlib
opts = {"py2exe": {
"packages" : ['matplotlib'],
"includes": ['scipy', 'scipy.integrate', 'scipy.special.*','scipy.linalg.*'],
'dll_excludes': ['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll',
'libgdk_pixbuf-2.0-0.dll']
}
}
setup(
windows = [{'script': "with_GUI.py"}], zipfile = None,
options= opts,
data_files = matplotlib.get_py2exe_datafiles()
)
But this gave me some error saying that there was version conflict with two files. So I changed the two files viz. dist/tcl/tcl8.5/init.tcl (in line 19) and dist/tcl/tk8.5/tk.tcl (in line 18). In my case I changed the version from 8.5.15 to 8.5.18. I found the location of the two files by looking at the path specified by the error in error log. Then the .exe worked just fine.
Problem:
I zipped the dist folder which contains .exe file. Then, I unzipped it on another computer but it is not working there. Following is the error it shows:
Traceback (most recent call last):
File "Moment_Final.py", line 5, in <module>
File "matplotlib\__init__.pyc", line 122, in <module>
File "matplotlib\cbook.pyc", line 33, in <module>
File "numpy\__init__.pyc", line 180, in <module>
File "numpy\add_newdocs.pyc", line 13, in <module>
File "numpy\lib\__init__.pyc", line 8, in <module>
File "numpy\lib\type_check.pyc", line 11, in <module>
File "numpy\core\__init__.pyc", line 14, in <module>
File "numpy\core\multiarray.pyc", line 12, in <module>
File "numpy\core\multiarray.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
Update:
If I install Anaconda Python 2.7 on the system, there is no error. But then, what is the use of py2exe.
I encountered the same issue. The solution has been found on the link below :
http://comments.gmane.org/gmane.comp.python.py2exe/4847
In short, two dlls from "C:\Anaconda2\Library\bin" were missing in the "dist" output of py2exe.
I get a python error when attempting to use xlwings. Just importing xlwings seems to be sufficient to trigger the problem.
Lewis-MacBook-Air:~ lewis$ python
Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, Oct 19 2015, 18:31:17)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import xlwings
>>> xlwings.__version__
'0.6.0'
>>> exit()
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/Users/lewis/anaconda/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/Users/lewis/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 47, in clean_up
if is_excel_running():
File "/Users/lewis/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 98, in is_excel_running
if proc.name() == 'Microsoft Excel':
File "/Users/lewis/anaconda/lib/python2.7/site-packages/psutil/__init__.py", line 539, in name
cmdline = self.cmdline()
File "/Users/lewis/anaconda/lib/python2.7/site-packages/psutil/__init__.py", line 592, in cmdline
return self._proc.cmdline()
File "/Users/lewis/anaconda/lib/python2.7/site-packages/psutil/_psosx.py", line 209, in wrapper
raise ZombieProcess(self.pid, self._name, self._ppid)
ZombieProcess: psutil.ZombieProcess process still exists but it's a zombie (pid=71)
Error in sys.exitfunc:
Traceback (most recent call last):
File "/Users/lewis/anaconda/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/Users/lewis/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 47, in clean_up
if is_excel_running():
File "/Users/lewis/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 98, in is_excel_running
if proc.name() == 'Microsoft Excel':
File "/Users/lewis/anaconda/lib/python2.7/site-packages/psutil/__init__.py", line 539, in name
cmdline = self.cmdline()
File "/Users/lewis/anaconda/lib/python2.7/site-packages/psutil/__init__.py", line 592, in cmdline
return self._proc.cmdline()
File "/Users/lewis/anaconda/lib/python2.7/site-packages/psutil/_psosx.py", line 209, in wrapper
raise ZombieProcess(self.pid, self._name, self._ppid)
psutil.ZombieProcess: psutil.ZombieProcess process still exists but it's a zombie (pid=71)
Lewis-MacBook-Air:~ lewis$
Calling python from Excel using Workbook.caller() is working fine.
I am running El Capitan 10.11.2 (Beta 5).
Any advice appreciated.
It seems that the version 3.3.0 of psutil is causing this, as logged here.
At the moment, downgrading to pip install psutil==3.2.2 should help until this is fixed.
update:
This has been fixed with v0.6.1