Emacs, python: Run "sudo pip install names" to install - python

Emacs 24.5
Python 2.7.12
If I start simple (Hello world) python script from shell - is OK. But if start more difficult script then return error:
python myscript.py "some_params"
ATTENTION! https://pypi.python.org/pypi/names/ package is requred to randgen human names.
Run "sudo pip install names" to install.
Traceback (most recent call last):
File "myscript.py", line 6, in <module>
import secretary
File "my_another_script.py", line 5, in <module>
import names
ImportError: No module named names

You need to install the external libraries you are using. names in this case is an external library that you need to install to make your script work.

Related

Problem using installed packages with PIP (possibly due to two Python versions)

When I try to use installed packages in Python, I nearly always run into the same error.
So I e.g. install a package like this: pip3 install mathplot and when I afterwards want to use it in Python3 (I use python3 in the command prompt), I run into the ModuleNotFoundError:
>>> import mathplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mathplot'
But when I run just python, the module is found and ready to use.
Any idea where this problem comes from and how I can get rid of it?
Thanks in advance

Not able to install bz2 in Python 3

I am not able to install the bz2 package in Python 3 Can please anyone guide
I followed the below commands
sudo yum install bzip2-devel
after that, I start my python 3.7 terminal and use the below command
import bz2
The error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/sysopt/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
Based on the comments and the /usr/local/sysopt path, I assume you've installed Python 3.7 from a source package.
When you did that, the Python configure script checked whether it has the bits to compile the bz2 module, and as you didn't have bzip2-devel installed during that time, the builtin bz2 module didn't get compiled.
You will need to recompile and reinstall Python 3.7 to get it included. At that point, you may also want to pay heed to any other optional modules that inadvertently don't get installed; sqlite3 tends to usually be one that ends up missing!

Problem importing a specific library with python 2.7.10

I am trying to install the following package in my MacOS High Sierra 10.13.6:
https://github.com/Michalychforever/CLASS-PT
When i run the make file everything looks to work fine. It not only generate an executable, which i can run by terminal using the ./ command, but also a python wrapper. The problem is related only with the former.
When i try to import the library i get the following message:
import classy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so, 2): Symbol not found: _zdotu_
Referenced from: /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
Expected in: flat namespace
in /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
I am using the built-in python version (i.e 2.7.10). I already installed the Xcode 10.1 together with command line commands. My .bash_profile is:
export PATH="/Users/thiagomergulhao/Library/Python/2.7/bin:$PATH"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Does anyone have any ideia what is causing this problem?

Custom python install location: tkinter problems

I'm using Ubuntu 14.04. While I have to retain my "main" python install as 2.7.6, I need to install 2.7.9 to be able to use ssl.SSLContext, to get Flask to deal with HTTPS requests.
However, if I just do:
sudo make install
or
sudo make altinstall
in the Python-2.7.9 directory, I ultimately get:
make: *** [libinstall] Error 1
EDIT: this appears at the end of sudo make install:
...
Compiling /usr/local/lib/python2.7/xml/sax/saxutils.py ...
Compiling /usr/local/lib/python2.7/xml/sax/xmlreader.py ...
Compiling /usr/local/lib/python2.7/xmllib.py ...
Compiling /usr/local/lib/python2.7/xmlrpclib.py ...
Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1
So I installed it to a custom directory by modifying the call to ./config, which did not yield the libinstall error.
However, when I try to import Tkinter into Python 2.7.9 (running from the custom directory) I obtain:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/repos/Python279/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
If I just go ahead and install the vanilla way (i.e., to a non-custom directory) and simply ignore the libinstall error I get, upon importing Tkinter:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: /usr/lib/python2.7/lib-dynload/_tkinter.so: undefined symbol: PyFPE_jbuf
Does anyone have any idea what is going on?
Following furas' suggestion, installing via the
Python 2.7 PPA maintained be Felix Krull worked spectacularly. Thanks Furas!
EDIT Some notes:
Because this PPA installs python2.7 (specifically v. 2.7.11, as of 1/29/2016), this obviated the need for a custom python install location
While the PPA website mentions that this doesn't include python-tk, provided you have installed it, python plays with it just fine (solving my problem)
First of all source code from a program must be configured, compiled, then installed. You can do this by:
./configure # Or ./config depending on the file name
make
make install
Second of all when you tried to import the module _tkinter you wanted to import the .py file which was called Tkinter.py
Try to use:
import Tkinter

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

Categories

Resources