use nodebox as a module for python 3.5 - linux

I'm trying to import everything from nodebox.graphics into my python 3.5 code but I get errors:
ImportError: No module named 'bezier'
To mention, this module exists in nodebox/graphics. As I searched in python documentations, I have to add the nodebox and pyglet folders into the directory of my code but that did not work.
I also didn't succeed in adding them to system directories.
How can I solve the problem and run my code properly?
P.S. I'm currently using ubuntu 16.04 if it matters.

I had the same error. Placing all the .py files except (and this is important) the __init__.py file in the main libraries folder fixed it for me. The final path should look like ~/lib/python3.5/site-packages/bezier.py

Related

Import a python module from within a packed module

So I builded a python package localy:
cgi#cgires:~$ pip list | grep mads
madscgi 0.1.0
Its nice! Afterwards I can use it in Jupyter Notebook, in iPython Shell, in Python Shell and even in python scripts outside the modules code. So it works as expected 100% outside the modules code:
Thats nice, but next I want to import code from one builded module (inside the package) into another python file (inside the package). Lets name it import_test.py and try it out:
So it fails if it is getting executed in the directory, where the package is build from. And it looks like, that the python interpreter is taking the parent directory (with the same name like the module) and this is failing.
Is is possible to enforce the usage of the installed pip-package?
As #MisterMiyagi pointed out, the problem was, that there were an upper folder which had the same name as the module.
Here: mads_cons is the upper folder from import_test.py. Therefore, the upper folder is getting imported instead of the via pip installed module. Thats it.
The file you want to import should either be in the same folder or referred to with the absolute path of it.
If that doesn't suit you, you can call sys.path
import sys
sys.path
You can keep your file in any of the directories sys.path returns.
Smart would be, if you keep the file inside.
......../site-packages/

Beginner having a problem with matplotlib

I am using the book Python Crash Course as a textbook. I was doing pretty well until I tried to use the Matplotlib library. The book gave the following command to install the library:
python -m pip install --user matplotlib
I entered this in the terminal window in Pycharm (the IDE I am using). It appeared to work, in that I got a series of messages indicating that files were being downloaded and installed on my computer. However when I attempted to import matplotlib.pyplot into an example piece of code I was trying to write, I got a ModuleNotFoundError: No module named 'matplotlib'
I assumed that the downloaded module went to the wrong directory, so I searched my hard drive to find a file or folder named matplotlib. I found several folders in different locations, but when I tried copying them into folders where I knew Pycharm could find it, it didn't seem to help. Can someone please clue me in to how I can use this module.
I am using windows 10 on an MS Surface 6.

Issue with python import for mapr_streams_python

I'm playing with the MapR Sandbox and would like to import some data in MapR stream using python. But I'm having an importing issue and I dont know why. I followed instructions from MApR website (see reference at the end of this post) and looked everywhere for a clue, but know I don't really know what else I can do. I tried with python 2.7 and python 3.6.
File "producer.py", line 1, in <module>
from mapr_streams_python import Producer
ModuleNotFoundError: No module named 'mapr_streams_python'
I have installed it globally like doc is telling me to do, the file is located in /usr/lib64/python2.7/site-packages for python 2 /usr/lib64/python3.6/site-packages for python 3
Someone has an idea?
Thank you
References
https://mapr.com/docs/60/AdvancedInstallation/InstallingStreamsPYClient.html
https://mapr.com/docs/52/MapR_Streams/MapRStreamsPythonExample.html
I noticed that the folder for the module was incorrectly named in the folder that it was installed at. After getting to the directory with the modules (/usr/lib64/python3.6/site-packages), just run this command:
cp -R mapr_streams_python-0.11.0-py3.6.egg-info/ mapr_streams_python
You should then be able to import the package in python.

Tensorflow: Object detection api error-no module named object_detection

I am using python 3.5 and Anaconda 4.2 and ubuntu 16.04. I get an error in train.py file (from object_detection import trainer: no module named object_detection).But I think that i have problem in python 3.5. Can anyone help me with this error?
It happened to me. Just copy the "object_detection" folder from "models" folder into the folder where you are running the train.py. I posted the link to the folder from github but you better copy the folder from your local files so it will match with your code perfectly in case you are using an older version of the object detection api.
There are more professional ways to solve the problem I think but I just used the easiest way to solve the problem.
Link to object_detection folder from tensorflow github: https://github.com/tensorflow/models/tree/master/research/object_detection
Move the object_detection folder to upper folder
cp /models/research/object_detection object_detection

Python 3.6 cx_freeze ModuleNotFoundError: No module named Tkinter

I froze a python 3.6 program with cx_freeze, and it worked just fine. But as soon as I tried to run it, I got this error message.
Does anyone know what to do? Please help!
try using
import tkinter
(small 't' instead of capital)
Try checking the dir names in the 'lib' folder (in my case it was 'build\exe.win-amd64-3.6\lib'). I had a similar issue (without the 'ImportError: DLL load failed...') and found that the 'lib' directory contained a "Tkinter" folder. Changing its name to lowercase 'tkinter' did the trick and made the .exe run just fine.
If you read the error more clearly, it stated in a comment that if importing _tkinter failed, your computer isn't configured to use tkinter. You should download tk and ttk to make it work.
And According to http://wiki.python.org/moin/TkInter :
If it fails with "No module named _tkinter" or "Tkinter", your Python configuration
needs to be modified to include this module (which is an extension
module implemented in C). Do not edit Modules/Setup (it is out of
date). You may have to install Tcl and Tk (when using RPM, install the
-devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in
the default locations, simply rerunning "make" should build the
_tkinter extension.

Resources