How do you downgrade pyinstaller using pip? - python-3.x

I am currently developing a program in python and I am converting this into a .exe file so I can share it. However, there have been many virus alerts and I have not been able to do this. I am using PyInstaller to convert my files. I believe this issue may be coming from the actual conversion itself. I have heard that the new version of PyInstaller is generating these issues. Many people have said to downgrade PyInstaller to an earlier version to avoid this issue.
So my question is: 'How do you downgrade a python module such as PyInstaller?'
And should I try using other modules to convert my files or should I stick to PyInstaller?
Thanks!

pip install --upgrade (package)==(version)
Add this command instead of (package) write your package which here you want pyinstaller and then in (version) add which version you want to of the pyinstaller.
MAKE SURE TO REMOVE THE BRACES ().

Have you tried pip install pyinstaller==3.6? In this case, I have chosen the version 3.6. You can choose other versions also.

Related

Is there currently any way to install mypy for python 3.7 and use with PyDev?

I tried to install mypy with "phyton -m pip install mypy" but it fails with an error about typed_ast that says it needs Visual C++ compiler but after installing that the error remains. I found several similar reports and notes that it can't be fixed due to the typed_ast thing, I don't know any details about that.
Is there a way to install mypy manually? Just copy a bunch of files somewhere?
I use Windows 10, Python 3.7, I updated to the latest pip.
Any help or hint is welcome
Thanks a lot
Martin
I found an answer myself.
I have python 3.7-32 installed and there is no appropriate wheel for typed -ast for this. This video
https://www.youtube.com/watch?v=XZrThBBpFlo
explains the problem and also gives a solution. I installed a 32-bit wheel from the link given and then installed mypy again and it finished successfully.
Now I will try mypy.
Good luck

openCV in python on Linux bombs out at show image [duplicate]

I'm having an error running simple code using cv2 module.
It's just:
import cv2
img = cv2.imread('sudoku.png',0)
cv2.imshow('image',img)
And it fails with the following error:
QObject::moveToThread: Current thread (0x1b74720) is not the object's thread (0x1e57d70).
Cannot move to target thread (0x1b74720)
I googled this error and tried a lot of things but it doesn't help. I tried installing without pip, I tried using step-by-step installation (from official OpenCV) but nothing helps.
When I run:
cv2.__version__
It returns 3.4.3
As noted already, the basis for this problem is discussed in opencv-python issue 46, and results from the duplication of the following libraries both on the host and the opencv-python distro libQtDBus libQtCore and libQtGui.
It has been lately addressed in the newest release of opencv-python. It is not a fix to the source code, rather the fix is to force pip to compile the newly available source via
pip install --no-binary opencv-python opencv-python
This will cause opencv-python to use the same libraries as the host, so the conflict no longer exists.
According to this issue posted on the OpenCV GitHub, this is a known issue that the developer states is damn near impossible to fix. It is apparently caused by a conflict in any Qt installations on the system with the Qt that is shipped with OpenCV. There are some suggestions floating around to remove the libqt5x11extras5 package from the system. This may fix it for some but anyone running these libraries on a Linux distribution that uses a window manager based on Qt will render their desktop environment unusable by removing this package (having tried it myself).
You can try building OpenCV from source using the WITH_GTK=ON option when running cmake which will use GTK instead of Qt, circumventing the conflict. However, this is hard to make use of in Python when using virtual environments.
I haven't spent the time to fully appreciate this problem, but as I understand this is caused by multiple conflicting versions of some plugin in the environment. I tried installing building opencv-python but there were errors with that approach. Another suggestion is to change your import order, but I've had mixed success with that, and I couldn't get it to work on a project today.
But I found a workaround that worked for me. Install opencv-python-headless instead of opencv-python. This will avoid installing the conflicting plugins. It may not work for you depending on what features of opencv you need.
$ pip uninstall opencv-python
$ pip install opencv-python-headless
The error was fixed on my system, by simply updating one library.
To find out where it is coming from, assuming Linux, try the following,
LD_DEBUG=files python -c "import cv2"
or,
LD_DEBUG=files python -c "import cv2 ; img = cv2.imread('myimage.png',0) ; cv2.imshow('image',img) ; cv2.waitKey(0)"
On my machine, it failed in one of the blas libraries. I updated that library and the code now runs without error.
This is an old bug you can find it discussed in a number of online communities.
My test code is as follows. Notably the error has not reoccurred, and apparently has nothing to do with Qt.
import cv2
img = cv2.imread('sudoku.png',0)
cv2.imshow('image',img)
cv2.waitKey(0)
To me, the solution to this problem was removing Anaconda, then installing pip followed by installing OpenCV with a simple pip install command.

"No module named wordcloud" after successful installation

After searching everywhere on here I found some solutions to my problem. At first, the error was that I needed Visual C++ 14.0 and that I could get it from a link that didn't work. So, I downloaded Visual C++ Build Tools and got Visual C++ 14.0.23026. That did not solve the problem.
I did some more searching and found that I could install it using wheel. So, I got wheel and got the .whl file from here as shown in the comments of this
post, making sure to get the correct version for my python version (3.6). Running python -m pip install wordcloud-1.5.0-cp36-cp36m-win32.whl worked, it seemed.
However, after restarting Pycharm, the IDE I use to run python files, it still didn't import it correctly. ModuleNotFoundError: No module named 'wordcloud'.
What am I missing here? Thanks!
EDIT: It works outside of Pycharm (just double clicking my python file), but I'd still like it to work in Pycharm.
I have the same problem and I've solved it.
When you create a project, you should choose 'inherit global site-packages
Or
You can use the terminal in the Pycharm to install the wordcloud.
You can also install wordcloud by File->Settings->Project:your project name->Project interpreter.

importing pygrib anaconda throws dependency issues

I have the following issue: I have installed anaconda 3 and installed a package called "pygrib" into my anaconda environment. Now when importing pygrib in a file in my environment, it will show me this error:
import pygrib
ImportError: libhdf5.so.10: cannot open shared object file: No such file or directory
As I am a noobie, I dont really know what to do with this information. I installed the h5py package and some other related ones, but it didnt resolve the issue. What to do?
This is a linking error with the HDF5 library. Are you building pygrib from source or using the conda-forge channel to install it via conda? When I use the conda-forge build of pygrib I get the same issue. The GRIB API from ECMWF (on conda-forge it is listed as ecmwf_grib) is what pygrib depends on and the HDF5 dependency comes from netCDF4 being used in the GRIB API library. Specifically, using the latest HDF5 (1.10.0 at this time) is what is causing a problem. Using HDF5 1.8.* instead allows pygrib to import properly.
To force conda to grab a specific version, just do:
conda install pygrib hdf5=1.8
This will get conda to solve the package specifications again with the older HDF5 library and likely clear up the issue. This assumes you are in the conda environment that you installed pygrib into. You could also create a new environment with conda create -n <env name> pygrib hdf5=1.8 if you wanted to.
In general, when you see these errors where a library is not found, it is often a matter of getting the right version of a library installed. With conda, this sort of thing happens when updating packages and a newer version of a library gets installed that a package you are using has not been properly linked with. As long as you can track down the package/library that is causing trouble, you can use the above procedure to start requiring certain versions of things get installed and conda should then update or downgrade things so that things work together again. Hopefully this makes sense and helps.
This part may or may not interest you, but what I cannot say for certain is where this problem originates. My guess is that it is something with ecmwf_grib and how it is built. That is where ldd shows the old HDF5 dependency showing up for my installation. If I can figure out the exact issue, I'll update this answer.

How to create a standalone exe using python 3.4

I have created an exe file using cx_freeze (python 3.4).
Along with the exe there is a library.zip,python34.dll and some .pyd file with it.How can i create a standalone exe so that it can be run on other systems where python is not installed.
A single exe file is all i want.Can this be achieved...??
This question was asked previously as well but i didnt find any suitable solutions in it.Help please.
Thanks
At first .pyd files are python native extensions written in either C or C++ for windows target platform. Next in order to get exe built you will going to need to have pyinstaller package installed (http://www.pyinstaller.org/). You can install it using either "pip install pyinstaller", "easy_install pyinstaller" or just specify it as a dependency within REQUIREMENTS.TXT or SETUP.PY of yours. But this package depends on pywin32 package which can only be installed either manually or with easy_install. It doen't support pip because the only bundle that is available is - exe file format. easy_install handles it though.

Resources