How to fix ModuleNotFound error in python building? - python

I trying to build the ungoogled chrome source from github. I was following the instructions in the link below, but I really do not know how to continue.
I installed python 2.7 and 3.7, set them in the PATH.
Used the git clone command and jumped the replace comands and the git checkout too, because I didin't got them.
So, I tried the "py build.py" command and got this error.
C:\Users\aquasp\ungoogled-chromium-windows>py build.py
Traceback (most recent call last):
File "build.py", line 24, in <module>
import buildkit.config
ModuleNotFoundError: No module named 'buildkit'
Is there any suggestions?
This are the commands that I was folowing:
git clone --recurse-submodules https://github.com/ungoogled-software/ungoogled-chromium-windows.git
# Replace TAG_OR_BRANCH_HERE with a tag or branch name
git checkout --recurse-submodules TAG_OR_BRANCH_HERE
py build.py
py package.py
https://github.com/ungoogled-software/ungoogled-chromium-windows

I'm assuming you are on a windows machine. Try running the dos 'which' command with an argument of 'buildkit' as follows:
which buildkit
The output will be the search of directories in the path variable of the windows machine as follows:
which: no buildkit in (/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1
etc...
'buildkit' is not found on path or the python.exe is not on the path.
Try 'which python' or 'which py' to test for python.exe or py in the machine path.
if python.exe is found output is as follows:
/c/Program Files/python/python
or if not found
which: no python found in (/c/WINDOWS/system32: etc...
Last but not least, add buildkit or python.exe or py to your machines path variable as follows:
set path=%path%;plus\new\path
C:\Users>echo %path%
C:\WINDOWS\system32;plus\new\path

Related

Conda doesn't see a module in the same directory

When I try to run a script in conda environment it gives me a ModuleNotFound error
(ldm) C:\Users\Иван\Documents\git\stable-diffusion>python scripts/txt2img.py --prompt "a photograph of an astronaut in space" --plms
Traceback (most recent call last):
File "scripts/txt2img.py", line 17, in <module>
from ldm.util import instantiate_from_config
ModuleNotFoundError: No module named 'ldm'
Here are the txt2img.py's lines causing the trouble
from ldm.util import instantiate_from_config
from ldm.models.diffusion.ddim import DDIMSampler
from ldm.models.diffusion.plms import PLMSSampler
But the main points are:
There is a folder called "ldm" containing everything needed
There are no complains from the compiler in the actual code editor
What I'm sure of:
The txt2img.py's directory is C:\Users\Иван\Documents\git\stable-diffusion\scripts\txt2img.py and the ldm's directory is C:\Users\Иван\Documents\git\stable-diffusion\ldm
Anaconda is added to my PATH environment variable
I'm trying to make it work in VSCode terminal (I set it up to run conda) but it's absolutely the same in the separate Anaconda Prompt
The problem does not occur with other projects
Is there a way to fix this?
The problem got resolved with typing in the following:
pip install -e .
I think it just installs all the packages from the project folder
As a quick solution try the following:
cd C:\Users\Иван\Documents\git\stable-diffusion
C:\Users\Иван\Documents\git\stable-diffusion> python scripts\txt2img.py --prompt "a photograph of an astronaut in space" --plms
In VSCode, do the following:
Add 'C:\Users\Иван\Documents\git\stable-diffusion' to your workspace
Open VSCode Terminal (ctrl + ~)
Follow the steps from here
Run your script
python scripts\txt2img.py --prompt "a photograph of an astronaut in space" --plms
Update based on comment:
You need to add an empty __init__.py inside all your folders. Refer here

Dockerized Django tests only look at first $PATH location

I'm running a Django test suite in a Docker container, and some of these tests use a program I've had to apt-get install (wkhtmltopdf). Now I can see that it's been installed correctly:
$ wkhtmltopdf --version
wkhtmltopdf 0.12.5
but for some reason the Django test can't use it. The installation location is definitely on my $PATH (third to last element):
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$ find / -name wkhtmltopdf
/usr/bin/wkhtmltopdf
However when I run tests I get a stack trace ending in:
OSError: No wkhtmltopdf executable found: "/usr/local/bin/wkhtmltopdf"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
Now it's absolutely correct that there is no /usr/local/bin/wkhtmltopdf, because it got installed elsewhere (/usr/bin/) but both those locations are on $PATH.
I've tried moving /usr/bin/ to the start of $PATH, but I then get the error:
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
presumably because it's now looking in /usr/bin/ for django when it's actually in usr/local/bin/, which is no longer the first location on $PATH.
I'm not sure if the problem is a Docker one, a Django one, a testing one, or just me misunderstanding one or more things going on here.
So it turns out that the project is using pdfkit as a wrapper for wkhtmltopdf, which includes setting the wkhtmltopdf path directly:
config = pdfkit.configuration(wkhtmltopdf=settings.WKHTMLTOPDF_BIN)
which after a quick look at the Django settings file was set to:
WKHTMLTOPDF_BIN = '/usr/local/bin/wkhtmltopdf'
Mystery solved! The fix in this case was to simply set it to the actual path desired (/usr/bin/wkhtmltopdf).

ImportError: cannot import name 'input_reader_pb2'

working on win10 64-bit
when i trying to train my model by E:\projectx\model-master\models-master>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
this error appear
File "train.py", line 49, in
from object_detection.builders import dataset_builder
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\dataset_builder.py",
line 27, in
from object_detection.data_decoders import tf_example_decoder
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\data_decoders\tf_example_decoder.py",
line 27, in
from object_detection.protos import input_reader_pb2
ImportError: cannot import name 'input_reader_pb2'
i do run protoc 3.4 protoc object_detection/protos/*.proto --python_out=.
but the error still exist
i check all thing and it is should be fine and work, it is going me mad!!
please help....
thanks
As you already compiled all .proto files in object_detection/protos/ . You should see python files which have '_pb2' like eval_pb2. If you can see these then go to models/research directory and run these code one by one:
python setup.py build
python setup.py install
From inside the object_detection folder:
protoc ../object_detection/protos/*.proto --python_out=.
This command will generate a *_pb2.py for each .proto file in the object_detection/protos/ folder.
Note: Is important to specify a path above object_detection, otherwise errors would occur, most likely:
object_detection/protos/ssd_anchor_generator.proto: File not found.
protos/anchor_generator.proto:8:1: Import "object_detection/protos/ssd_anchor_generator.proto" was not found or had errors.
protos/anchor_generator.proto:17:5: "FlexibleGridAnchorGenerator" is not defined.
If the error persists probably you are in the wrong folder, take a look at the output message to see from where it is trying to import the file and execute the command in the right directory.
As last resort: Download the object_detection module from https://github.com/tensorflow/models/tree/master/research
place it in your working directory, enter it and re-execute the command above.
It will surely works as local modules have import priority over sys.path.
If not, the error message would be probably different from the one reported and the problem lies on the tensorflow installation or the protobuf compiler; as here where the problem was caused by the protoc version.
other useful links: https://github.com/tensorflow/models/issues/5264
Maybe you haven't added module slim to PYTHONPATH.It can be done by running below code inside models/research directory.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Seems that you didnt compile protobuf.
For solving it:
Download the latest protoc exe here: https://github.com/google/protobuf/releases (in your case should be win32)
Rename that folder to "protoc"
Put that folder inside models/research
in models/research via console, launch:
protoc/bin/protoc object_detection/protos/*.proto --python_out=.
I dont know exactly if that command will work on windows, but you have to be sure that you are using the protoc compiler that you downloaded (v.3.6) instead of the protoc in your enviroment.

git executable not found in python

I was trying to clone a git repo with access key, but when I am trying to run it, It throws an exception saying git executable not found.
But i have installed git and the in_it.py shows correct path "C:\Program Files\Git\bin" Also I have installed gitpython to use the library in python
here's my code...
import git
git.Git("D:/madhav/myrep/").clone("#github.com:myrepo/scripts")
========= and it throws the following exception =================
Traceback (most recent call last): File
"C:\Users\1096506\Desktop\gitclone.py", line 1, in <module>
from git import Repo File "C:\Users\1096506\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\__init__.py",
line 84, in <module>
refresh() File "C:\Users\1096506\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\__init__.py",
line 73, in refresh
if not Git.refresh(path=path): File "C:\Users\1096506\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py",
line 293, in refresh
raise ImportError(err) ImportError: Bad git executable. The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()
All git commands will error until this is rectified.
This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exception
Example:
export GIT_PYTHON_REFRESH=quiet
I had the same issue. What I did is:
I went to: System Properties -> Environment Variables
On System Variables Section I clicked Path, Edit and Move Up.
Environment Variables
Edit and Moved Up two places from the bottom
Error occurs because git is not in the path. So its not able to import git module.
Couple of ways to resolve it.
As suggested above adding the git binary path to environment variable path.
If git is not being used directly in the module and its only a dependent module import thats throwing this exception before importing git we could add
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
and import git after this line, this would suppress the error caused due to git import
Had the same problem got it to work thanks to Muthukumaran. Just make Muthukumaran answer more clear.
Follow these steps:
import os
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
import git
See if you have installed Git in the OS.
If not install git first this will solve your error.
Centos
sudo yum -y install git
Ubuntu/Debian
sudo apt-get install git
Mac Os
sudo brew install git
This solved my problem.
Make sure you're not in an inaccessible directory on *nix, such as when you've just been root and then done a su username
you may still be in root's home folder and that will trigger this error (assuming you have the correct environment variables set, and have sourced the .profile or .bashrc etc with source ~/.bashrc )
which git
/usr/bin/git
I was getting this error even after setting the environment:
in ~/.bashrc
# for bench
PATH=$PATH:/usr/bin/git
export PATH
GIT_PYTHON_GIT_EXECUTABLE=/usr/bin/git
export GIT_PYTHON_GIT_EXECUTABLE
cd
and it's working
$ bench --version
WARN: Command not being executed in bench directory
5.3.0
I came across similar problem recently and installing git followed by restarting Windows Powershell CommandLine solved the problem. May it helps.
For those who are using a Lambda layer with it. It worked adding as the comment above says just adding GIT_PYTHON_REFRESH=quiet as an environment variable.
Execute GIT_PYTHON_REFRESH=quiet in your terminal and then try to run the code.

made a shell to run script on startup, suddently it gives me an importerror

I followed this guide: guide to create a startupfile which excecutes a python file on startup.
in step 2 it says I have to test the startupfile I just created and suddently my script says:
Traceback (most recent call last):
File "Display.py", line 1, in <module>
import pyowm
ImportError: No module named pyowm
the python file works perfect if I run it directly.
what I allready tried: run pip again to see if the lib was okay
check the /usr/local/lib/python3.4/dist-packages folder to see if it was there and it is.
I think this is a python issue and not a RaspberryPi issue thats why I uploaded it here.
runned by:
sh launcher.sh
inside is:
#!/bin/sh
# launcher.sh
# navigate to home directory, then to this directory, then execute python script, then back home
cd /
cd /home/pi/arduino/Python/Main/Master
sudo python Display.py
cd /
Simple fix: define the version of python which will be used. It used python 2.7. Yet the lib was for 3.4.

Categories