I'm working on the implementation of an algorithm which was made to run on Windows and that I need to run on Linux now. It's written with Python 3.7 (but I made it run with Python 3.4 on windows and it worked).
Now, I'd like to run the algorithm on Linux as I said, however when I run the .py file that launches the whole algorithm, I got an error that says:
ImportError : cannot find name 'etree' from 'lxml' (/lib/Python-3.7.4/Lib/lxml/__init__.py)
I don't know how to resolve this error: the lxml library does exist to the indicated path and I installed Python 3.7 (because I originally tried to run it with Python 3.8, then tried 3.4 as it worked on Windows, but each time it couldn't find some method from one or another library...)
You will need to install the library as its not part of the standard Python library, you can install it using PIP by running the following command:
$ pip install lxml
Related
As you can see I have imported the modules correctly using pip install. I googled a bit why the module was not imported and I realized I have to add it to PATH. I did that too but now there is a new error something about a syntax error
File "pygame/__init__.py",
self.reason = f"{exc_type.__name__}: {self.info}"
Is this because my chrome book can not run Pygame or is the problem something else?
Picture of my terminal with the error:
you need to run python3. to start python 3. Just running python starts python 2.7.
you have your installed packages in python 3.9 version while your python environment is 2.7, look for python3 executable and try with that version
I have been building an application on Linux using python pygobject, and now I need to distribute it on Windows.
I first installed pygobject via msys2 (as per the official pygobject documentation)
Now, using msys2/mingw32, I can run my program typing
python3 main.py
But when I try to freeze it into a .exe with Pyinstaller, and try to run the produced .exe
If I Don't use --onefile, I get an import error on the _struct module (whereas "import _struct" works in python shell)
If I use --onefile, I get the Following error :
error:
lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.dll could not be extracted!
fopen: No such file or directory
I’m using the devel version of Pyinstaller. I know next to nothing on Windows OS… does anyone know how to fix that error ?
It sounds like you were on the right path, unfortunately you ran in to a bug in PyInstaller. The good news is that the issue with the No module named '_struct' error is now fixed and released in version 3.6 and later. I would recommend using the --onedir mode of PyInstaller, you should be able to successfully package a GTK app for Windows.
I recently installed the opencv package using pip install and I wrote a small code to test it (cvtest.py). The code runs through the python idle shell but running it though the command prompt gives the error
Error while finding module specification for 'cvtest.py' (ModuleNotFoundError: __path__ attribute not found on 'cvtest' while trying to find 'cvtest.py')
I tried uninstalling and reinstalling both python and the package. looking up the system path using python -m site gives these results. I am the only user of my laptop.
sys.path = [
'C:\\Users\\Kareem Mostafa\\Desktop\\Assignments\\computer vision',
'G:\\Python37\\python37.zip',
'G:\\Python37\\DLLs',
'G:\\Python37\\lib',
'G:\\Python37',
'G:\\Python37\\lib\\site-packages',
This is the code I am using
import cv2
x=cv2.imread('backpack for sale.jpg',0)
cv2.imshow('x',x)
update: the problem is happening with all the py files I am having whether they require imports or not. apparently python is looking for _init_.py for all the files as if they are packages. Any idea what is going on?
For anyone else that had this problem (assuming kareemostafa has fixed it now!)
Removing the .py suffix on the python -m command fixes this problem, it appears -m only requires module names whereas running it directly as a python file (no -m option) requires the .py suffix
In your case python -m cvtest should be sufficient.
We seem to be running into a problem downloading opencv which is a dependency for gym-gazebo. Seems opencv works for Python 2.7 but gym-gazebo requires Python 3.5.
We tried fixing it by going into the bash file and tweeking a bit with Python path. We got to a point where opencv can be imported but rospy which is an essential module won't get imported.
We have this error :
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
Any advice?
Python modules with binary code need to be built for the specific python version.
Install opencv for python 3.5 using whatever python package manager is on your system (conda / pip etc).
If you are on windows you might want to bookmark Unofficial python builds
Following the 'Automate the Boring Stuff' website. Using Windows 10 and Python 3.6.
I am not sure if the problem is to do with my install location of Python itself.
I have followed this post but when following the Environment element of the instructions the Python path isn't showing and I can't add the Python path (unsure as to why).
Python seems to be located at C:\Users\James\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.6
If I try and install pyperclip using pip in PowerShell I get the error message "No module named site". I have also tried following various other instructions in order to tell PowerShell where Python is located, but to no avail.