SkyNet is publicly available as an open-source software at https://bitbucket.org/jlippuner/skynet. I am having problems installing this software. I am using Ubuntu, and I have downloaded all needed packages using apt. All tests pass (not at first, but after restarting), but the problems start when I try to run the example code.
As instructed at the bitbucket page, I have used CMake to try to install the package, and all files seem to be installed, and the tests work.
The first line in the code is from SkyNet import *, but this just returns No module named 'Skynet' found. I have tried to reinstall and using different versions of Python, but it doesn't seem to work. Can anyone help me?
Going through the Skynet documentation install page I found this,
For python to find the Skynet module the directory in which it exists has to be added to PYTHONPATH environment variable.
Replace install_dir with directory where the Skynet module has been installed to.
echo "export PYTHONPATH=<install_dir>/lib:\$PYTHONPATH" >> ~/.bashrc
An alternative approach would be to add the path where Skynet module exists to sys.path at the top of your script file.
Example
import sys
sys.path.append("/usr/lib/Skynet")
from Skynet import *
Here is a link to documentation on how python resolves module imports
Related
Im getting nowhere with the following error on my Raspberry Pi:
My own Python script calls a function from another module named BlackBean.py which in turn imports other modules called "netaddr" and "configparser". The problem is that I just cant seem to get past the import error which tells me " No Module named netaddr, or if I comment out that import then it also errors with No Module named configparser. So I know its a path issue but I just cant seem to get it fixed!
The Blackbean.Py script starts like this:
import broadlink
import ConfigParser
import sys, getopt
import time, binascii
import netaddr
import BlackBeanSettings
import re
from os import path
from Crypto.Cipher import AES
SettingsFile = ConfigParser.ConfigParser()
SettingsFile.optionxform = str
SettingsFile.read(BlackBeanSettings.BlackBeanControlSettings)
def execute_command(etc.........
The BlackBean.py file is in my project SkyHD folder at /home/pi/SkyHD.
The "netaddr" and "configparser" files & folders were installed by pip in /home/pi/.local/lib/python2.7(and python3.5)/site-package folders.
sys.path has the above folders in its list and Ive also edited .bashrc and added PYTHONPATH=${PYTHONPATH}:/home/pi/.local/lib/python2.7/site-package:/home/pi/.local/lib/python3.5/site-package:/home/pi/SkyHD:../
but none of this works. I guess it must be something basic but I just cant work it out! help!
Also, some more info, when I first install all the files and run my program everything works fine and it finds the files ok with no problems, its only when I reboot it fails to find the files.
Its fixed.
Python looks for imported modules in 3 places, the first being the folder you launched the python script from; so for me the obvious answer is to import the modules I need directly into my own Project folder (/home/pi/myproject). This worked just fine, it works every time even after reboot, which was my main problem before. No need to create or alter PYTHONPATH, no need to mess around with entries in .bashrc or try to change the python path entries. Here are the steps:
Upgrade PIP to version 9.0.3 (not ver 10) with
pip install --upgrade pip==9.0.3
then install the required modules with the following
pip install --target=/home/pi/your_project_folder module_name
so for me it was... pip install --target=/home/pi/SkyHD netaddr
Im sure this is not best practice, but my Raspberry Pi only has this one project to run and having modules imported into the Projects folder just isnt an issue.
Hope this helps some others with the same problem.
You've provided insufficient information. Specifically, details about the python command being used to run your script such as its version (python -V) and its module search path if you do
env -u PYTHONPATH python -c 'import sys; print(sys.path);'
Similarly you can easily simplify the problem. What happens if you do python -m netaddr?
Obviously in the above commands substitute the actual python command being used to run your script.
And, as #BoarGules mentioned in his comments to your question, you should never, ever add directories to PYTHONPATH for different python versions unless you know that the modules in those directories has been written to work with python2 and python3.
I am using python 2.7.13 and
I am facing problems importing ruamel.yaml when I install it in a custom directory.
**ImportError: No module named ruamel.yaml**
The command used is as follows:
pip install --target=Z:\XYZ\globalpacks ruamel.yaml
I have added this custom directory to PYTHONPATH env variable
and also have a .pth file in this location with the following lines
Z:\XYZ\globalpacks\anotherApp
Z:\XYZ\globalpacks\ruamel
There is another app installed similarly with the above settings
and it works.
What am I missing here?
PS: It works when I install in site-packages folder
also it worked in the custom folder when I created an init.py file
in the ruamel folder.
EDIT:
Since our content creation software uses python 2.7 we are restricted to
using the same.We have chosen to install the same version of python on all
machines and set import paths to to point to modules/apps locacted on shared
network drive.
Like mentioned it works in pythons site-packages but not on the network drive
which is on the PYTHONPATH env-variable.
The ruamel.yaml-**.nspkg.pth and ruamel.ordereddict-*-nspkg.pth are
dutifully installed.Sorry for not giving complete details earlier.Your inputs
are much appreciated.
Okay, so, I'm actually a beginner in programming Python, and I only found out yesterday how you were supposed to encode pip install ModuleName in the Python command line and not in the interactive shell. I'm trying to download a lot of modules, such as the Send2Trash module, Pyperclip, Requests, Beautiful Soup, and Selenium.
Before I checked the forums about installing modules, I found out how we needed to have the pip tool. I'm a Windows user, but for some reason, I didn't have the 'Scripts' folder installed when I downloaded Python. I didn't know we needed it, so I used raw scripts from GitHub, setup.py, and copy pasted the script into the File Editor in Python, ran it in the interactive shell, and tried to import the module I needed. It worked for the Pyperclip and the Requests module; no errors popped up after I imported them using import pyperclip or import requests, but when I tried the same procedure for the rest of the modules I needed, there were some errors.
Also, when I tried to download the modules on pypi.python.org, I tried to open it using the interactive shell, but then something pops up, 'The file's encoding is invalid for Python3.x...', and when I click 'OK', it's going to say 'Failed to Decode', and close everything.
So, after reading forum after forum, I found out how to download pip, and was also able to download setuptools and wheel. I'm not sure if it's really already downloaded, but I was able to get the 'Scripts' folder that wasn't there before, so I guess so. I also already went into my PATH using the edit environment for your account thing, and I edited the Path variable so its value would lead to my 'Scripts' folder. Please do tell me if I did the right thing here.
So, following the advice of the forums, I tried to install the modules I needed by typing pip install ModuleName in the Python command line instead of the interactive shell, but it still gave me a Syntax Error. I also tried it in Command Prompt, typing the same code pip install ModuleName, but when I clicked Enter, nothing happens; no errors or anything. It seemed like my install was accepted, but when I tried importing the module in the interactive shell, it still gave an Import Error.
Please tell me what I did wrong throughout my process, and how to properly install the modules I need. I would include pictures into this, but it seems I can only add two before my reputation becomes 10, and I'm pretty new here, so... If there's anything I need to elaborate on about my problem, don't hesitate to ask, and I'll try my best.
You say you use windows so you need to understand pip.
pip is a program that installs python modules. You can even use easy_install instead of pip.
some pip commands
pip list -- lists out already installed modules.
pip search <module name> -- searches new modules.
pip -h -- more pip commands you want.
pip installs modules from CMD prompt not from python shell.
Even after installing modules some modules doesn't run as import module
they need to be imported as from module import function.
refer the pip help command and install modules.
DO NOT SAVE SCRIPT FILES IN PYTHON ROOT FOLDER YOU MAY FACE SOME PROBLEMS
Happy Programming!!!
After a whole lot of searching and trying out, I found the solution to my problem. For future Python users who encounter the same thing: always install your modules in the root folder.
In my case, my Command Prompt was automatically inside the C:\Users folder, which caused some problems because I couldn't download my module in there. Once I typed in cd C:\Python34, which was my root folder, I could successfully download the modules I needed using pip install ModuleName.
I'm trying to get a Python package to install to my home directory because I don't have the privileges to install it system-wide.
The package is PyProj, and I am trying to install it using python setup.py install --home=~ (with Python 2.4.3), as recommended in the Python documentation. The package compiles successfully and copies itself to what I assume are the correct directories (the directory ~/lib64/python/pyproj appears during install).
But, when I load Python up and type import pyproj, I'm told ImportError: No module named pyproj.
Any thoughts on what might be going on?
You'll need to set PYTHONPATH to tell Python where to locate your locally installed packages.
For example:
[you#home]$ export PYTHONPATH="~/lib64/python"
Or, to do this within the interpreter (or script):
import sys, os
sys.path.append(os.path.expanduser("~/lib64/python"))
For more information on how Python locates installed modules, see section on The Module search Path in docs.
~/lib64/python/pyproj is not part of your PYTHONPATH. There are two or three ways around this, depending on your needs.
The first is to directly modify the path in your module, suitable if you're only going to use it from one module. As noted in the comments, this method does not do expansion on the '~' character.
import sys
sys.path.append('/home/username/lib64/python')
import pyproj
The second way is to add ~/lib64/python/pyproj to your system's PYTHONPATH, through whatever method your system suggests. A line in .bash_profile is shown below.
export PYTHONPATH=$PYTHONPATH:~/lib64/python/pyproj
See the Python Documentation for more details.
I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by default in the considered version of Python. However, I have some troubles. When I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "", line 1, in File "/home/verrtex/opt/lib/python2.6/sqlite3/init.py", line 24, in
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: No module named _sqlite3
As I have already told to, the possible reason of this problem is that the module in tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. This explanations is supported by the fact that I do not have _sqlite3.so file in my "/home/verrtex/opt/lib/python2.6/lib-dynload" directory. So, this is the problem I have to solve (I have to get this file to this directory).
I found out that to solve this problem I have to "install sqlite3 and recompile Python". I also found out that the problem can be solved by "building from source and moving the library to /usr/lib/python2.5/lib-dynload/".
However, it is not clear to me what exactly should I do. Should I install python module called "sqlite3" or I should install sqlite-database? By the way, I have already sqlite-database installed globally by the administrator. Can I use it or I still have to install my own database? By the way, I do not have root permissions. Can it be a problem? Or I need to install a python module? Is absence of root permissions a problem, in this case?
I also has been told to, to take source files from SQLite Download Page, extract archive, move to expanded directory and execute:
./configure
make
make install
Then I have to copy newly compiled files to my Python directory. Should I copy all newly compiled files? And to which exactly directory should I copy (my Python directory have some subdirectories)?
Would very appreciate any help, because I stack with this problem for a wile.
P.S. My OS is CentOS release 5.3 (Final).
Your sys.path is likely not pointing to your locally installed copy, or you're not running the Python 2.6.2 you think you are.
If none of that is the case, you need the SQLite development headers (sqlite-dev or whatever), and then recompile Python. You need to pay attention at the end of the compile, because it complains about what it didn't build due to missing dependencies.
EDIT: Reread question.
EDIT 2: Also, please don't do this:
from module import *
Do this:
from module import what_i_need
import module2
Although you might have found your solution, I just wrote mine down for someone who are stuck in the same problem.
My OS is CentOS 6.3(Final) with python2.6.
I install python2.7.3 in my system, but the problem's still there. (_sqlite3.so should be in /path/to/python2.7.3/lib/python2.7/lib-dynload after python2.7.3 has been installed. Because before python2.7 was installed, sqlite-autoconf-3071502.tar.gz was installed.)
I then copy the /path/to/python2.6/lib/python2.6/lib-dynload/_sqlite3.so to the python2.7's path. And type in the python-shell:
>>> import sqlite3
or
>>> import _sqlite3
No error reports.
Unfortunately, the damn error appeared as before when I run my python script.
I install sqlite-devel(sudo yum install sqlite-devel or download here), and then reinstall python2.7.3 again. Run my python script again. Thank goodness! The damn error finally solved.