pyinstaller on virtualenvs, No module named Import Error - python

I am trying to create virtualenvs for my script. When I use pyinstaller without virtualenvs (just sudo pyinstaller myscript.spec) everything works fine. After that I activate virtualenvs and do same thing (pyinstaller myscript.spec) . When I try to execute this two files the standart one (first one) works but the one that I create with virtualenvs gives ImportError: No module named 'sip'. I did not use sip in my script and did not import it anywhere. I do pip3 install sip and compile script again but it did not change anything. What is this error and how can I fix it?

Try sudo apt-get install python-sip to install Ubuntu's version

Related

How to run python script using keyboard lib as root and also have access to the packages on the project venv?

I have a python project which uses a specific venv. I tried to use the "keyboard" package on it, but I got the error "ImportError: You must be root to use this library on linux.". Then I installed the package with sudo python3.9 -m pip install keyboard and tried to run the script like sudo python3.9 path/to/script. It seems that the root problem was solved, but now I get ModuleNotFoundError: for every package I used on the script that was installed on the project's venv.

How to resolve Python import module?

I'm on Ubuntu 20.4. When I execute a Python script, I get the following error and sys.path.
I installed the packages with pip3 and they are located in
/usr/local/lib/python3.8/dist-packages
When I look at the installed packages for python3 and python3.8 interpreter, I see "binance" package installed and recognized.
I tried to set PYTHONPATH to point to my project folder, but that didn't help either.
echo $PYTHONPATH --> /algos_python
You have installed binance from PYPI but you are not using it. You are using python-binance and you need to install it. (Using python3 -m pip install python-binance) and then run your code again. See this for more info on this.
Try these:
python3 -m pip install python-binance
If you are calling your file binance.py (Or have a file/folder named that in your directory), and then trying to import from binance.client, python will look in your binance.py file instead of the library. So try renaming your local file.

"No module named pefile" even though I have installed pefile

I have Python 2.7 and Python 3.8 on the same computer
I am trying to get this to work: https://github.com/countercept/python-exe-unpacker
The requirements are:
pefile==2017.9.3
unpy2exe==0.3
uncompyle6==2.11.5
xdis==3.5.5
pycrypto==2.6.1
configparser==3.5.0
And I guess the other stuff is installed correctly (not sure). But when I try to currently run this thing with python python_exe_unpack.py -i [programname.exe]
I get the error:
C:\Python27\python.exe: No module named pefile
I've run both of these commands:
py -m pip install pefile==2017.9.3
py -m pip install pefile==2019.4.18
and the problem persists.
Any idea what might be going wrong?
You should use pip freeze to obtain the list of installed packages. Probably your py and python executables aren't the same, try py python_exe_unpack.py -i [programname.exe]. Also check which paths you using to obtain that package:
import sys
print(sys.path)
You can add extra paths through PYTHONPATH environment variable or just sys.path.append("/path/to/folder") with path where is you're installed pefile.

How to import module installed by pip to a custom directory

I'm writing a plugin for an app, and found that packages I install with pip are apparently being ignored, so I'm trying to install them within my plugin's directory using
pip install --ignore-installed --install-option="--prefix=[plugins-folder]" [package-name]
This creates a folder structure lib/python2.7/site-packages/[dependencies] which is fine by me, except I can't figure out how to them import those dependencies. Even if I manage to import the main package, it will break because it can't find it's own dependencies which are also in that same directory structure.
I suggest that you should use virtual python environment. virtualenv for python2/python3 and python3 -m venv for python3.
You python environment seems orderless and you should isolate each environment for each python app.

pyInstaller: ImportError: No module named 'praw'

I wanted to pack my script using pyInstaller. I run pyinstaller file.py -F, file is created successfully, but when running I get ImportError: No module named 'praw'. So I created new file containing only import praw and run pyinstaller file.py -F --hidden-import=praw but still get the same error when running.
I was unable to find anything similar, most issues were solved by using --hidden-import.
Any ideas on how it can be solved?
EDIT:
praw is installed inside virtual environment and running the script directly works as expected.
Seem pyinstaller run outside the virtualenv.
Try switch to your virtualenv and run:
python -m PyInstaller -F file.py
I'll recommend to look at pyenv or virtualenv. Activate these env's and install the praw module here. This should work.
This command might help you out. It installs the Praw module for you. Make sure you have pip installed!
pip install praw
I found a way to solve the issue:
When using Python2.7, or starting the shell like python2, we need to do
python2 -m pip install --user praw
to make sure they are linked during installation.
Same idea for python3 shell.

Categories

Resources