Here is my error :
File "C:\Program Files\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in <module>
ModuleNotFoundError: No module named 'nets'
screenshot
I have already change the python path but it doesn't change anything
Maybe in a Windows environments, capital code couldn't check differently and differs from linux file system.
It has already BUILD file inside slim folder. Let's move BUILD to BUILD.old, then You can build slim package
c:\foo\bar\models\research> cd slim
c:\foo\bar\models\research\slim> move BUILD BUILD.old
c:\foo\bar\models\research\slim> python setup.py build
c:\foo\bar\models\research\slim> python setup.py install
on windows
in the C:\tensorflow\models\research\slim directory run
python setup.py build
python setup.py install
P.S
models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!!
use the one specific for slim
Try to copy nets or slim folder to .....\site-packages\object_detection-0.1-py3.5.egg
See if this solution works.
I met same problem with you, since we are both in Windows Environment. What am I doing is that, I added little codes in the header of model_builder_test.py.
import sys
sys.path.append("....../tutorial/models/research")
sys.path.append("....../tutorial/models/research/slim")
......
import tensorflow as tf
from google.protobuf import text_format
from object_detection.builders import model_builder
......
You need to make sure that the tensorflow/models/research/ and slim directories are added to PYTHONPATH (see the installation instructions).
Either run the following
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
or add it to the end of your ~/.bashrc so that it gets run automatically whenever you open a new terminal.
Related
I have a question that I assume has a simple answer, but for some reason I am struggling to find it on my own. I have created and activated a virtual environment with virtualenv, and I am trying to install all the necessary packages in order to create a requirements.txt file.
I have, for example, a Python file that begins like this:
import xml.etree.ElementTree as ET
from lib.project import Projector
from lib import writer
import os
import datetime
from datetime import timedelta
from datetime import datetime
import pprint
When I try to run this file from the virtual machine, I receive the following error:
Traceback (most recent call last):
File "readMap.py", line 2, in <module>
from lib.project import Projector
ModuleNotFoundError: No module named 'lib.project'
My problem is that I'm not sure why the virtual environment can't find project.py. My directory structure is:
regiaoSul
lib
__init__.py
arrival_conversion.py
coord_conversion.py
message_conversion.py
project.py
route_conversion.py
stop_conversion.py
wkt_parser.py
writer.py
readMap.py
json_generator.py
The import on line 2 implies lib is a module rather than "a simple repository".
I will try running the script with the flag -m. Something like this -
python -m script_name
make sure to drop the .py extension when you run with -m flag.
Another advice: you don't need to install python files to the virtual environment, they are not some external libraries. They only need to be present (with the same order of packaging) when you run your script.
Thanks to everyone who responded. I believe the issue was some sort of dependency problem. In readMap.py I had imported writer from lib, and in writer.py I had imported Projector from project. I moved the function that required Projector from writer.py to readMap.py and it worked.
I still don't fully understand why this was a problem. Until recently I had been running my scripts in PyCharm and they all worked with the structure I had. It was only when I tried to run them from the command line in my virtual machine that they didn't work.
If anybody would like to explain the distinction to me and what the exact problem was with my imports, feel free to.
I sometimes face the same issue. A solution is to add the path to sys.path by:
import sys
sys.path.insert(0, "/path/to/your/package_or_module")
When calling the kmodes package like this:
# I have also tried
# from kmodes.kmodes import KModes
from kmodes.kprototypes import KPrototypes
ModuleNotFoundError: No module named 'kmodes'
As suggested by #648trindade, all I had to do was install the package. That's not included in Anaconda by default.
I had same issue. It turned out that I named my test file as kmodes.py, and current directory is in sys.path. so python use my test file as the library.
If you have set the system path to some folder having kmodes.py file, just rename your script as something else, everything is fine.
Or you just remove the sys.path line from the code and restart the compiler
I'm trying to run a Python script from the Windows shell, but when I do
python path\to\file\script.py
I get an error "DLL load failed: The specified module could not be found" and it traces back to the line where I import numpy.
C:\Users\Admin>python path\to\file\script.py
Traceback (most recent call last):
File "path\to\file\script.py", line 8, in <module>
import numpy as np
File "C:\Users\Admin\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\Admin\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
The weird part is that when I run it in an editor like Spyder, numpy imports just fine. Can someone help me?
Thanks
It's fixed Anaconda path issue. Check your %PATH% if it's correctly defined.
Source: https://github.com/numpy/numpy/issues/12957
This is a common problem when installing python packages, mainly in windows.
Numpy and other packages have bindings to C++ code that require some special dependencies.
Rather than trying to get the dependencies exactly right for compiling the package, you can use a precompiled "wheel" file from one of several sources.
I use Chris Gholke's site
download the .whl file and install using
pip install directory/path/package.whl
edit: and as a note, the python environment you access from powershell or cmd is different from the anaconda environment in spyder. One of the differences between conda and pip is that conda installed precompiled packages while pip does not.
I solved my issues with Numpy DLL load issues by replacing Anaconda3 with WinPython.
I have a requirement to import a dependency using it's source directory. (Names are obfuscated because this is for work).
So I used conda develop which adds a conda.pth file in site-packages
[user#user folder]$ conda develop /path/to/source/
added /path/to/source/
completed operation for: /path/to/source/
The new module resolves, when I run the code using python.py, but then it doesn't resolve dependencies in conda itself. ie:
(dq) [user#user]$ python file.py
Traceback (most recent call last):
File "file.py", line 10, in <module>
import utils as utils
*...
Various stack trace with import getting resolved
...*
import Pyro.errors
ImportError: No module named errors
So Pyro is a package installed in the dq conda environment, but for some reason through the source code imported through conda develop, it can't find the import. I'm not sure if this itself is an issue, but the developer of the code also had the ingenious idea of naming the module Pyro.py and then importing Pyro.errors at the top of the module. Is there a way to have conda imports take precedence over the source code? Or be resolved in the first place?
Thanks in advance for the help!
Probably you should change the package of Python you work with to another newer or older one from the Conda page shown by Jupyter as shown in this .
I am attempting to train a TensorFlow model in Windows 10 using these steps: https://github.com/tensorflow/models/tree/master/attention_ocr#requirements
I have installed virtualenv for Windows (following this example)
The source command is not recognized by Windows. Are the additional steps to the virtualenv command required for Windows, or is there an alternative usage of the source command?
Note that the subsequent pip install commands worked (pip, tensorflow_gpu), but when I attempt to train using train.py I get the following error:
File "train.py", line 27, in <module>
from tensorflow.contrib.tfprof import model_analyzer
ImportError: cannot import name 'model_analyzer'
It looks like your virtualenv is configured correctly, but the code you are trying to use imports tf.contrib.tfprof, which is not currently (as of TensorFlow 1.2) supported on Windows.
However, since tf.contrib.tfprof is only used to provide profiling information, you should be able to run the code by manually removing the following line from train.py:
Line 27: from tensorflow.contrib.tfprof import model_analyzer
...and passing the flag --show_graph_stats=false when running the script.