I have build .dll of _caffe.cpp on Windows (Release, x64).
I changed extension .dll to .pyd and trying to import it in python:
import caffe
File "\caffe-master\python\caffe\__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver
File "\caffe-master\python\caffe\pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver
ImportError: DLL load failed: The specified module could not be found.
What does it mean, some module of dependencies missing which was included in project in Visual Studio, where I build this dll?
You need to add Python Caffe to PYTHONPATH. For example:
export PYTHONPATH=$PYTHONPATH:/home/username/caffe/python
For windows :
Adding /caffe/Build/x64/Release/pycaffe to system path(path) works for me, and I think the best way to do it is :
New a system variable : PYTHON_PKG = /caffe/Build/x64/Release/pycaffe;
Include PYTHON_PKG in path : path = %PYTHON_PKG%; %OtherDirs%
After I did this, I get PKG missing google.internal, then I did pip install google.internal in CMD. It works.
Once you have a compiled and built caffe, try
echo 'export PYTHONPATH=/path/to/caff-dir/python'
Also, you may need to run following:
pip install -r requirement.txt
Related
So I am trying to use this repository on my computer but I cant seem to import a local module (Agent.pyx) and use functions from that file. The error I get is:
ModuleNotFoundError: No module named 'RLAgent.Agent
Screenshot of error
Link to repository
You have to install the package manually
Since Agent.pyx is a .pyx file, you will need to first build it. The README file in the linked repo also mentions this. So you need to move to the RLAgent directory and execute the setup instruction as:
cd RLAgent
python3 setup.py build_ext --inplace
This will build the required .c and .so file which will then enable it's import in other files such as Train.py which is where the import is throwing an error.
i am working on a long project in Django and suddenly i faced this error:
import asyncio
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\asyncio\__init__.py", line 17, in <module>
from .streams import *
ModuleNotFoundError: No module named 'asyncio.streams'
I tried to instal it using : pip install asyncio, But again it gave some errors :
Traceback (most recent call last):
File "c:\users\appdata\local\programs\python\python38\lib\shutil.py", line 587, in _rmtree_unsafe
with os.scandir(path) as scandir_it:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\AppData\\Local\\Temp\\pip-req-tracker-ua43f6rj'
please Tell me how can i fix it . I am Using Python 3.8.1
Please reinstall python3.8.1 for windows 10
Packages and modules in python can be imported when they appear in the PYTHONPATH environement variable or in the sys.path list.
On each PYTHONPATH expanding, will ends up in the sys.path list.
so make sure that, the instalation of your asyncio was successeful and its path exist in the sys.path list. how you check? see below:
in comand line or in script.py type:
import sys
p_asyn=r'C:\Users\AppData\Local\Programs\Python\Python38\lib\asyncio'
if p_asyn not in sys.path:
print('asyncio not in the sys path list! :-(')
sys.path.append(p_asyn)
its better to append new paths to the PYTHONPATH rather than editing the sys.path.
Anywa, if the module you are trying to import (asuncio) is a built in lib/module you should check if the pyhton installation was successful and the path environement variable edited correctly and has all paths that should be.
in windows make sure that python installation dir appears in the path. if not use the set command,
set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
Python usually stores its library (and thereby your site-packages folder) in the installation directory. So, if you had installed Python to C:\Python\, the default library would reside in C:\Python\Lib\ and third-party modules should be stored in C:\Python\Lib\site-packages.
This attended to windows users.
for further reading, enter the link here
using_py2
using_py3
I'm trying to install pyfluidsynth on windows. I used pip install pyfluidsynth in the command prompt, but when I tried to import fluidsynth in my python code I get:
ModuleNotFoundError: No module named 'FluidSynth'
When I tried to install FluidSynth (by using pip install fluidsynth) another binding package was installed with FluidSynth 0.2 from several years ago.
Can anybody help with specific details on how to install pyfluidsynth on windows and use it?
import FluidSynth
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'FluidSynth'
For recent FluidSynth versions there do not seem to be pre-built binaries for ms-windows available. (Note that development is now done on github; the sourceforge site is stale.) The latest source code releases are here.
But the FluidSynth wiki has instructions for building it on ms-windows.
Note: FluidSynth (more precisely, its shared library) is a requirement for using pyfluidsynth. See the README.
For me the following worked:
Go to the following link and download the pre-compiled (?) fluidsynth dll.
Add the directory of your fluidsynth dll to the path environment variable.
In the pyfluidsynth package. find the "fluidsynth.py" file, and edit the part where it's looking for the library "lib = find_library('fluidsynth')..." to search for the dll name, which was "libfluidsynth64" for the 64 bit version.
For whatever reason, (maybe version mismatch), the functions "fluid_synth_set_reverb_full" and "fluid_synth_set_chorus_full" are not supported, so comment those lines out from "fluidsynth.py".
And that's it. Save "fluidsynth.py" launch cmd, go into python, and import fluidsynth.
I haven't tested all the functionality of fluidsynth, but using pretty_midi, I was able to at least play midi through instrument soundfonts.
Hope this helps!
Installing fluidsynth on Windows
Download fluidsynth binaries from github: https://github.com/FluidSynth/fluidsynth/releases
Add extracted zip file’s bin to the path:
Eg: C:\Users*Your Username Here**** YOUR path to extracted zip ***\fluidsynth-2.1.6-win10-x64\bin
Download fluidsynth python library: the repository for python fluidsynth is:
https://github.com/nwhitehead/pyfluidsynth.
https://github.com/nwhitehead/pyfluidsynth/archive/master.zip
Once extracted, it must be installed:
python setup.py install
The extracted master.zip has fluidsynth.py This python file is the file to “import” into the python code. In the test folder it has example.sf2 which is used in an installation test: paths to these two files need to be set to your own locations.
import time
import fluidsynth
fs = fluidsynth.Synth()
fs.start()
sfid = fs.sfload("example.sf2")
fs.program_select(0, sfid, 0, 0)
fs.noteon(0, 60, 30)
fs.noteon(0, 67, 30)
fs.noteon(0, 76, 30)
time.sleep(1.0)
fs.noteoff(0, 60)
fs.noteoff(0, 67)
fs.noteoff(0, 76)
time.sleep(1.0)
fs.delete()
The above python code sample plays a single note. Getting this to work confirms everything is working.
For me, next works:
Call pip install --upgrade pyfluidsynth
Download precompiled DLL from: https://zdoom.org/downloads#Support
If you use 64x version rename file from libfluidsynth64.dll to libfluidsynth.dll
Place it into C:\Windows\System32
i compiled caffe successfully in my ubuntu machine but cannot import in python.
Caffe is installed /home/pbu/Desktop/caffe
i tried adding the /home/pbu/caffe/python path to sys.path.append, still not working
i am trying to import caffe
root#pbu-OptiPlex-740-Enhanced:/home/pbu/Desktop# python ./caffe/output.py
Traceback (most recent call last):
File "./caffe/output.py", line 13, in <module>
import caffe
File "/home/pbu/Desktop/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver
File "/home/pbu/Desktop/caffe/python/caffe/pycaffe.py", line 10, in <module>
from ._caffe import Net, SGDSolver
ImportError: No module named _caffe
This happens when you have not run make for the python files separately.
Run make pycaffe soon after running make in the Caffe directory.
You may have to set the path to the python library correctly in Makefile.config
Adding to the above best answer. After you run make for python files by running make pycaffe where you ran your previous makes. Then you have to export that python path by running export PYTHONPATH=<path-to-caffe>/python. You can choose to run this everytime before running a python code which utilizes caffe or add it to your ~/.bashrc.
Well, I use the cmake-gui for making Caffe. There you need to set the Python paths to the Anaconda-python:
PYTHON_EXECUTABLE <path_to_anaconda_home>/bin/python2.7
PYTHON_INCLUDE_DIRECTORY <path_to_anaconda_home>/include/PYTHON2.7
PYTHON_LIBRARY <path_to_anaconda_home>/lib/libpython2.7.so
You should build caffe and pycaffe using the command:
cd $FRCN_ROOT/caffe-fast-rcnn
make -j8 && make pycaffe
and before the compilation, you should create a Makefile.config file and set the corresponding library path, such as python.
More details are presented on the web: bgirshick/py-faster-rcnn.
What's more, when I run the "Beyond the demo" section, it seams that if I Create a symlink of the folder "VOCdevkit" as "VOCdevkit2007" which turns out to be "can't find the dataset". So, I change the folder name as "VOCdevkit2007", and it runs well.
I posted my Caffe install notes (my architecture: Arch Linux x86_64 | Intel i7 CPU ...) in an Anaconda Python 2.7 virtual environment here:
Caffe Installation Notes
https://gist.github.com/victoriastuart/fb2cb22209ccb2771963a25c06221213
I also encountered the (downstream) "Import caffe error," for which I needed to resolve my $PYTHONPATH to complete the make compilation and get Caffe finally installed, and also to be able to import it (in Python).
I successfully built and installed VTK-5.4 with Python bindings from source. Yet, when I try to import VTK in python it gives the following Traceback error
File "", line 1, in
File "/usr/local/lib/python2.6/dist-packages/VTK-5.4.2-py2.6.egg/vtk/init.py",
line 41, in from common import *
File "/usr/local/lib/python2.6/dist-packages/VTK-5.4.2-py2.6.egg/vtk/common.py",
line 7, in from libvtkCommonPython import *
ImportError:
libvtkCommonPythonD.so.5.4: cannot open shared object file: No such file or directory
So I am wondering what I am missing? I have tried adding /usr/local/lib/vtk-5.4 to both PATH and PYTHONPATH environment variables and still get the same result. Any hints or suggestions?
NOTE:
libvtkCommonPythonD.so.5.4 exists in /usr/local/lib/vtk-5.4 as a symlink to libvtkCommonPythonD.so.5.4.2
Test if adding /usr/local/lib to your $LD_LIBRARY_PATH helps:
In a shell:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
If it works, make it permanent by (adding /usr/local/lib to /etc/ld.so.conf) _ (running 'ldconfig -n /usr/local/lib')