In my script I have imported lxml module. I made an executable file from my script using pyinstaller on Ubuntu. When I run the executable file in terminal I get the following error:
Traceback (most recent call last):
File "<string>", line 15, in <module>
File "/home/yaa110/workspace/Python27/src/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/yaa110/workspace/Python27/src/PyInstaller-2.1/process/build/process/out00-PYZ.pyz/lxml.html", line 42, in <module>
ImportError: cannot import name etree
How can I fix it?
I'm using Python 2.7.5 on Ubuntu
Related
I installed phenix (phenix-installer-1.17.1-3660-intel-linux-2.6-x86_64-centos6) on my CentOS 7 system according the installation guide (https://www.phenix-online.org/documentation/install-setup-run.html). The original python version (/usr/bin/python) in my system is 2.7.5, but I installed anaconda3, so the output of "which python" command is "~/software/build/anaconda3/bin/python".
I tried to study the p9-sad tutorial and run the command "phenix.run_example p9-sad", but it gave the following error information:
Examples to be run: p9-sad
Running PHENIX example: p9-sad Fri Jan 17 15:04:44 CST 2020
Working directory: /home/sunyp/Documents/tutorial/PHENIX/p9-sad
Starting run now ... please wait a moment
Error processing line 1 of /home/sunyp/software/build/anaconda3/lib/python3.7/site-packages/google_auth-1.7.1-py3.6-nspkg.pth:
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/home/sunyp/software/build/anaconda3/lib/python3.7/importlib/util.py", line 14, in <module>
from contextlib import contextmanager
File "/home/sunyp/software/build/anaconda3/lib/python3.7/contextlib.py", line 5, in <module>
from collections import deque
File "/home/sunyp/software/build/anaconda3/lib/python3.7/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/lib/python2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/build/../conda_base/lib/python2.7/site-packages/site.py", line 73, in <module>
__boot()
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/build/../conda_base/lib/python2.7/site-packages/site.py", line 22, in __boot
loader.load_module('site')
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 570, in <module>
main()
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 557, in main
known_paths = addsitepackages(known_paths)
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 178, in addpackage
import traceback
File "/home/sunyp/software/build/anaconda3/lib/python3.7/traceback.py", line 3, in <module>
import collections
File "/home/sunyp/software/build/anaconda3/lib/python3.7/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/lib/python2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Does it mean that phenix requires python2 rather python3, but there is python3 in my system, so the error came out? And how to solve the problem? Thank you in advance.
Regards,
Yeping Sun
Solely based on /home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/lib/python2.7/site-packages/reprlib/__init__.py Phenix contains a Python 2.7 environment.
You could maybe try running your code with /home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/bin/python or something to use that Python interpreter, but it's hard to tell since Phenix source is not openly available.
Your environment probably contains path to python2.7.5
Check your PYTHONPATH
This doesn't work with Python 3 for obvious reasons. To remove it:
unset PYTHONPATH
I am getting the below error while using the command:
python get-pip.py
Error:
c:\Python>python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "C:\Users\dell\AppData\Local\Temp\tmpa0q8wceq\pip.zip\pip\__init__.py", l
ine 26, in <module>
File "C:\Users\dell\AppData\Local\Temp\tmpa0q8wceq\pip.zip\pip\utils\__init__.
py", line 27, in <module>
File "C:\Users\dell\AppData\Local\Temp\tmpa0q8wceq\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 35, in <module>
File "c:\Python\lib\plistlib.py", line 65, in <module>
from xml.parsers.expat import ParserCreate
File "c:\Python\lib\xml\parsers\expat.py", line 4, in <module>
from pyexpat import *
ImportError: DLL load failed: The specified module could not be found.
I'm pretty sure that pip comes with python 3 and up. If you have troubles running only "pip" from the terminal i'd recommend you try: python -m pip ...
Try to use the 'Alternative instructions' from this post.
Hope this can help.
I am a Python newbie, trying to package a python script as an exe.
I installed pywin32 from here and downloaded pyinstaller from here.
I've kinda been following this video and when I try to package my file as at 4:21, I get the following error:
F:\Softs\PyInstaller-3.2.1\PyInstaller-3.2.1>python pyinstaller.py test.py --onefile
Traceback (most recent call last):
File "pyinstaller.py", line 14, in <module>
from PyInstaller.__main__ import run
File "F:\Softs\PyInstaller-3.2.1\PyInstaller-3.2.1\PyInstaller\__main__.py", line 21, in <module>
import PyInstaller.building.build_main
File "F:\Softs\PyInstaller-3.2.1\PyInstaller-3.2.1\PyInstaller\building\build_main.py", line 32, in <module>
from ..depend import bindepend
File "F:\Softs\PyInstaller-3.2.1\PyInstaller-3.2.1\PyInstaller\depend\bindepend.py", line 38, in <module>
from ..utils.win32.winmanifest import RT_MANIFEST
File "F:\Softs\PyInstaller-3.2.1\PyInstaller-3.2.1\PyInstaller\utils\win32\winmanifest.py", line 97, in <module>
from PyInstaller.utils.win32 import winresource
File "F:\Softs\PyInstaller-3.2.1\PyInstaller-3.2.1\PyInstaller\utils\win32\winresource.py", line 20, in <module>
import pywintypes
File "C:\Python34\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Python34\lib\site-packages\win32\lib\pywintypes.py", line 98, in __import_pywin32_system_module__
raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes34.dll)
I looked up the error and I can only find solutions for -
ImportError: No system module 'pywintypes' (pywintypes27.dll)
which didn't work for me. Could somebody suggest where I am going wrong? A hint would be good.
The pywintypes38.dll file is actually installed in the folder path:
C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\pywin32_system32
I copied these files from here to this new path:
C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\win32\lib
and, it worked fine for me.
I use last version pyinstaller, python 2.7.5, OSX
And when I try pack this code:
import Crypto.Cipher._AES as AES
import Crypto.Hash._SHA256 as SHA256
if __name__ == '__main__':
c = AES.new('1234567890123456')
cipher = c.encrypt('blabblabblabblab')
print(cipher.encode('hex'))
h = SHA256.new('blabblabblabblab')
print(h.hexdigest())
python pyinstaller.py /Users/alexey/secure_backup/cryptotest.py -F
It successful, but this output has occurs when I run program from console:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/alexey/Downloads/pyinstaller-develop/PyInstaller/loader/pyimod03_importers.py", line 382, in load_module
exec(bytecode, module.__dict__)
File "build/bdist.macosx-10.9-intel/egg/Crypto/Cipher/_AES.py", line 7, in <module>
File "build/bdist.macosx-10.9-intel/egg/Crypto/Cipher/_AES.py", line 6, in __bootstrap__
ImportError: dlopen(/var/folders/nd/1m2t9wmx4jv1gdw_h0s9sp3w0000gp/T/_MEI81X1du/Crypto/Cipher/_AES.so, 2): image not found
--hidden-import=Crypto.Cipher._AES also not work
I wrote a program using PyQt4.QtGui and QtCore,I packaged it into exe,and it works good on my computer,but it can't run on others' computer
The error is this:
cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in <module>
File "baidu.py", line 6, in <module>
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1607, in _handle_fromlist
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_with_frames_removed
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1525, in _find_and_load_unlocked
File "ExtensionLoader_PyQt4_QtGui.py", line 11, in <module>
ImportError: DLL load failed: 找不到指定的模块。
The packaged files are:
├─_bz2.pyd
├─_hashlib.pyd
├─_socket.pyd
├─_ssl.pyd
├─baidu.exe
├─icudt49.dll
├─icuin49.dll
├─icuuc49.dll
├─LIBEAY32.dll
├─libGLESv2.dll
├─lxml.etree.pyd
├─PyQt4.QtCore.pyd
├─PyQt4.QtGui.pyd
├─PyQt4.QtNetwork.pyd
├─python33.dll
├─Qt5Core.dll
├─Qt5Gui.dll
├─Qt5Network.dll
├─Qt5PrintSupport.dll
├─Qt5Widgets.dll
├─sip.pyd
├─SSLEAY32.dll
└─unicodedata.pyd
I just used "cxfreeze baidu.py --base-name=Win32GUI --target-dir d:\123" to package it.
I wonder if I missed some arguments when using cxfreeze result in this problem,and how to package it to exe.Thank you
d3dcompiler_43.dll is needed to run pyqt