ImportError: No module named 'deployment' - python

Not sure whether I should be posting this on askubuntu or here.
I am trying to perform object detection using Tensorflow. I am therefor following this tutorial (this link shows the exact issue I am facing).
When running this script, I get this error:
$ python3 train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
Traceback (most recent call last):
File "train.py", line 51, in <module>
from object_detection import trainer
File "/usr/local/lib/python3.5/dist-packages/object_detection-0.1-py3.5.egg/object_detection/trainer.py", line 33, in <module>
from deployment import model_deploy
ImportError: No module named 'deployment
According to the info I found online and the video I linked above I have to execute this command:
export PYTHONPATH=$PYTHONPATH:`pwd`/slim
While being in the tensorflow/model/ directory. Yet, it doesn't solve my issue. And I don't really know what I should check in order to find out what is causing this persistent issue.
Could someone help me out?
Thanks
EDIT:
exactly what I do:
(tensorflow) xxx#yyy-ThinkPad-X200:~/Downloads/models/research/build/lib/object_detection$ cd ../../../../
(tensorflow) xxx#yyy-ThinkPad-X200:~/Downloads/models$ export PYTHONPATH=$PYTHONPATH:`pwd`/slim
(tensorflow) xxx#yyy-ThinkPad-X200:~/Downloads/models$ cd ~/Downloads/models/research/build/lib/object_detection
(tensorflow) xxx#yyy-ThinkPad-X200:~/Downloads/models/research/build/lib/object_detection$ python3 train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
Traceback (most recent call last):
File "train.py", line 51, in <module>
from object_detection import trainer
File "/usr/local/lib/python3.5/dist-packages/object_detection-0.1-py3.5.egg/object_detection/trainer.py", line 33, in <module>
from deployment import model_deploy
ImportError: No module named 'deployment'
(tensorflow) xxx#yyy-ThinkPad-X200:~/Downloads/models/research/build/lib/object_detection$

If you are installing from a clone of the tensorflow/models github you need to be inside models/research folder when you run the command:
$ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Notice the extra `pwd` to your command.
I still had problems until I ran from within models/research:
$ python setup.py build
$ python setup.py install
$ python slim/setup.py build
$ python slim/setup.py install
Note: In your case you may need to run python3 instead of python.

This work for me:
Copy relevant deployment folder from the \models\slim directory
paste it to Python\Lib\site-packages directory
then run again.It will work!

It's PYTHONPATH not PYTHONPAT. You're missing H in your export statement.

As of now, the slim folder has been moved to models/research. So if models is in the /home directory, do the following to resolve the issue:
1- Open the ~/.bashrc and add the following line to the end of the file:
export PYTHONPATH="$PYTHONPATH:/home/models:/home/models/research/slim/"
3- Close the file and do source ~/.bashrc

Related

Issue with Python 3 Imports when using a Shell script

I have the following scenario:
A Python3 Package (meross_iot) installed through pip and located in
~/.local/lib/python3.7/site-packages
A Python script (meross_electricity.py) that imports from this package: from meross_iot.controller.mixins.electricity import ElectricityMixin
A shell script (launcher.sh) that is meant to be a wrapper so that the .py script is run at startup:
#!/bin/sh
# launcher.sh
# navigate to home directory, then to this directory, then execute python script, then back home
cd /
cd home/pi/Documents
sudo python meross_electricity.py
cd /
If I simply execute the .py file everything works as expected, imports done, etc. If I try to run the .sh script I get the following error:
pi#home:~/Documents $ ./launcher.sh
Traceback (most recent call last):
File "meross_electricity.py", line 4, in <module>
from meross_iot.controller.mixins.electricity import ElectricityMixin
ModuleNotFoundError: No module named 'meross_iot'
Can someone please help me solve this issue?
Thanks!
Installed package with sudo worked .
Answer based on comment by #KlausD

libdouble-conversion.so.1: cannot open shared object file: No such file or directory

I'm trying to run a python program called Button python3 Button.py but it doesn't work, i have the next error
Traceback (most recent call last):
File "Button.py", line 1, in <module>
from PyQt5.QtCore import *
ImportError: libdouble-conversion.so.1: cannot open shared object file: No such file or directory
even though i have the libdouble-conversion.so in /usr/lib/x86_64-linux-gnu
You probably do not have libdouble-conversion.so.1 as this is not available, for instance in Ubuntu 20.04. I solved a similar problem for another program by linking the .3 library like this on Ubuntu 20.04:
sudo ln -s /usr/lib/x86_64-linux-gnu/libdouble-conversion.so.3 /usr/lib/x86_64-linux-gnu/libdouble-conversion.so.1
Chances are that this will also work for you.
Reinstalling libdouble-conversion1 by executing sudo apt install --reinstall libdouble-conversion1 solved the issue for me.
Reference: https://answers.ros.org/question/336354/rviz-fails-in-fresh-melodic-install-libdouble-conversion-not-found/

Pyinstaller create an executable with external libraries

I am trying to create an executable file (exe) for a Python script that I written in PyCharm.
When I run the script from the PyCharm is working fine but when I try to run it as an individual .py or try to run the exe I am getting an error.
The issue I believe is with the "from infi.devicemanager import DeviceManager" library.
from infi.devicemanager import DeviceManager # Used for the retrievement of Device manager information
dm = DeviceManager()
dm.root.rescan()
devs = dm.all_devices # Get all the devices to a list called devs
for d in devs:
print (d.description)
I get following error:
PS C:\Python> python.exe .\tests.py
Traceback (most recent call last):
File ".\tests.py", line 1, in <module>
import infi.devicemanager # Used for the retrievement of Device manager information
ModuleNotFoundError: No module named 'infi'
PS C:\Python> pyinstaller -F .\tests.py
PS C:\Python\dist> .\tests.exe
Traceback (most recent call last):
File "tests.py", line 1, in <module>
ModuleNotFoundError: No module named 'infi'
[15072] Failed to execute script tests
Is there a way to include this library to the exe file so anyone without python can run this script?
I am open to suggestions.
Thank you in advance!
=== UPDATE ===
Full script can be found here
https://github.com/elessargr/k9-serial
My answer assumes that the interpreter that has infi.devicemanager is C:\Python\venv\Scripts\python.exe as stated by OP in the comments
So there is virtual environment named venv. You need to activate the virtual environment and install PyInstaller in it.
C:\Python>venv\Scripts\activate
(venv)C:\Python>
Note (venv) in front of your shell - that means virtual environment venv is activated
Now install PyInstaller
(venv)C:\Python>pip install pyinstaller
-- here it will install pyinstaller --
now you can test that both pyinstaller and infi.devicemanager are installed in venv
(venv)C:\Python>pip list
it should list both packages among some others. now
(venv)C:\Python>pyinstaller -F C:\Python\tests.py --hidden-import=infi.devicemanager
--here it will create the exe --
if I was right it should work now
EDIT: It looks like infi is using __import__(pkg_resources), so the command should be
(venv)C:\Python>pyinstaller -F C:\Python\tests.py --hidden-import=infi.devicemanager --hiden-import=pkg_resources

How to solve the traceback error, when it is not a code issue?

So I downloaded this project (https://github.com/alectrocute/flasksaas) on my machine. Interesting is, that on my other computer everything works great, but not on this one.
I am stuck at the point, where I want to initialize the database with following command:
$python manage.py initdb
I reinstalled python, the modules etc., but it doesn't help.
I checked my system environment variables in the settings (OS: Windows), everything seems fine.
Error which occurs:
Traceback (most recent call last):
File "manage.py", line 4, in <module>
__init__.py, line 6, in <module>
app.config.from_object('app.config')
NameError: name 'config_dev' is not defined
Expected result:
"SQL database has been created."
After looking at the repo's Makefile, you'll find what each make target means:
install : run $ pip install -r requirements.txt
dev : copy (or link) the config_dev.py to config.py
prod : copy (or link) the config_prod.py to config.py

Building Yocto linux image - "bitbake image-full" error

I am trying to build the Yocto linux image. I am following the process given in Sergey's Blog. Unzip the file:
$ 7z x Board_Support_Package_Sources_for_Intel_Quark_v0.7.5.7z
Unzip meta-clanton_v0.7.5.tar.gz:
$ tar xzvf Board_Support_Package_Sources_for_Intel_Quark_v0.7.5/meta-clanton_v0.7.5.tar.gz
Change directory to meta-clanton_v0.7.5:
$ cd meta-clanton_v0.7.5
Run setup.sh:
$ ./setup.sh
Source poky/oe-init-build-env script, giving it the build directory (yocto_build) as a parameter:
$ source poky/oe-init-build-env yocto_build
Run bitbake to build the image:
$ bitbake image-full
But I am getting the following error:
Traceback (most recent call last):
File "/usr/bin/bitbake", line 275, in <module>
ret = main()
File "/usr/bin/bitbake", line 222, in main
bb.msg.init_msgconfig(configuration.verbose, configuration.debug,
AttributeError: 'module' object has no attribute 'init_msgconfig'
Please help.
Thanks in advance.
I couldn't find the 0.7.5 version, so I've tried this on the 1.0.0 version.
Extracting meta-clanton-v1.0.0.tar.gz
cd meta-clanton_v1.0.0
./setup.sh
. poky/oe-init-build-env yocto_build
bitbake image-full -e
Running bitbake image-full does also start the build without any issue. (I haven't let it complete though.)
I'm slightly worried about your traceback, which includes "/usr/bin/bitbake". If you have installed a bitbake package on your build-machine, please uninstall it. The poky-git repo does include it's own copy of bitbake, which will ensure that you're the version of bitbake you're using is compatible with the rest of your meta-data.
(I'd also suggest updating to the latest meta-clanton release).

Categories

Resources