pyconfig.h missing during "pip install cryptography" - python

I wanna set up scrapy cluster follow this link scrapy-cluster,Everything is ok before I run this command:
pip install -r requirements.txt
The requirements.txt looks like:
cffi==1.2.1
characteristic==14.3.0
ConcurrentLogHandler>=0.9.1
cryptography==0.9.1
...
I guess the above command means to install packages in requirements.txt.But I don't want it to specify the version,So I change it to this:
cat requirements.txt | while read line; do pip install ${line%%[>=]*} --user;done
When install cryptography,it gives me the error:
build/temp.linux-x86_64-2.7/_openssl.c:12:24:fatal error:pyconfig.h:No such file or directory
#include <pyconfig.h>
I don't know how to solved this , I have tried a lot of methods ,but failed. my system is centos 7, and the version of python is 2.7.5(default).
Besides, Is there any other scrapy frame which is appliable for a large number of urls . Thanks in advance

For Ubuntu, python2
apt-get install python-dev
For Ubuntu, python3
apt-get install python3-dev

I have solved it by myself. for the default python of centos, there is only a file named pyconfg-64.h in usr/include/python2.7/,So run the command
yum install python-devel
Then it works.

for python3.6,
apt-get install python3.6-dev
and
apt-get install libssl-dev libffi-dev

i use python 2 on ubuntu and got the same problem when installing cryptography.
after i run this command
apt-get install python-dev libssl-dev libffi-dev
then it works.

For Python 3.7 on Debian, the following works for me.
apt-get install python3.7-dev
and
apt-get install libssl-dev
You may also need:
apt-get install libffi-dev

On a Debian based distro (AntiX distro), together with apt-get install python3-dev, I also installed rust, to complete successfully the pip3 install cryptography command. So, I gave:
$ sudo apt-get install build-essential curl python3-dev libssl-dev libffi-dev
$ sudo curl https://sh.rustup.rs -sSf | sh
When prompted (Figure 1), type 1 and hit Enter on your keyboard.
Once it completes, you have to give following commands:
$ source $HOME/.cargo/env
$ source ~/.profile
$ pip3 install cryptography

Related

ns3, Python3 has no module named 'ns'

I am using a virtual box to build network simulator 3(ns3), Ubuntu version: Linux Server 20.04 LTS
the Linux command that I had executed are
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc g++ python python3 -y
sudo apt-get install python3-setuptools git mercurial -y
sudo apt-get install zip unzip
apt-get install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake -y
sudo apt-get install -y python-gi-cairo
sudo apt-get install -y gir1.2-gtk-3.0
sudo apt-get install -y python-dev
sudo apt-get install -y python3-dev
sudo apt-get install -y qt5-default
sudo apt-get install -y python3-pygraphviz
sudo apt install python3-pip
sudo apt-get install -y graphviz libgraphviz-dev
sudo pip3 install pygraphviz --install-option='--include-path=/usr/include/graphviz' --install-option='--library-path=/usr/lib/graphviz'
Then I use the bake to install the ns3 through following this page: install ns3 with bake
although the "bake.py show" tell me that pygraphvix is Missing, but since it is not an essential dependency, so I ignore it and continue build the ns3
after i successfully built the ns3, I follow the instruction here to execute the "./waf shell" command in the folder "/source/ns-3.29"
then I run the command and get the error:
root#ns3simulator:/home/ns3/source/ns-3.29# python3 examples/wireless/mixed-wired-wireless.py
Traceback (most recent call last):
File "examples/wireless/mixed-wired-wireless.py", line 54, in <module>
import ns.applications
ModuleNotFoundError: No module named 'ns'
Could anyone please help me for this?Thanks in advance.
The problem
"import ns.applications"
ModuleNotFoundError: No module named 'ns'
is because there is a problem with the ns-3 installation and it is not able to do python binding itself and you need to manually configure it.
In my case, I have python 2.7 also installed
Go to
-> cd [PATH-to-your-ns3.29]
-> /usr/bin/python2.7 ./waf configure
it will enable the python binding like this
Waf configuration
after this when you can see the python binding enabled you can run your python script without any error.
Hope it helps !!!
./ns3 configure --enable-python-bindings
Then run the python example. The libraries should get built.
Here

Why can't I install python3.6-dev on Ubuntu16.04

I am trying to install Python 3.6-dev with this command:
sudo apt-get install python3.6-dev
but I'm getting this error:
E: Unable to locate package python3.6-dev
E: Couldn't find any package by glob 'python3.6-dev'
E: Couldn't find any package by regex 'python3.6-dev'
Can anyone help? Why am I getting this error and what is the correct way to install the package?
sudo add-apt-repository ppa:deadsnakes/ppa \
&& sudo apt update \
&& sudo apt install python3.6
Edit:
The following PPA has been disabled, see discussion here and the new PPA here . So use the PPA mentioned above instead.
Original answer:
As mentioned by omajid the package is not availible in 16.04. But if you need it in 16.04 you can get it by adding for example the personal package repository of Felix Krull:
sudo add-apt-repository ppa:fkrull/deadsnakes
This ppa worked like a charm on ubuntu 16.04. Posting here for others.
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
For those who tried to install python-3.6 and got same error as that one above. This can help you as well us it helped me fix out the pb.
Open terminal then run command to add the PPA:
sudo add-apt-repository ppa:jonathonf/python-3.6
Then check updates and install Python 3.6 via commands:
sudo apt-get update
sudo apt-get install python3.6
Now to make sure you had install successufly just run python3.6-v or python3.6
For more details check here "How to Install Python 3.6.1 in Ubuntu 16.04 LTS"
Note: Linux 16.04 use python v 2.7 as default one if u needa use
python 3.6 in your project just set python-3.6 as default version for
this project. It's better then use sudo update-alternatives ...
command then your terminal will vanish :(.
The package is too new. It's not available in the older 16.04 release. It's available in the newer Ubuntu 16.10.
This ppa:jonathonf did not work for me.
ppa:deadsnakes
is working fine for now.
What worked was:
Open a terminal
Execute the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
sudo add-apt-repository ppa:deadsnakes/ppa
Guess they changed the name of repo.

Cannot import installed python package

I'm trying to install python-numpy package on my ubuntu 14.04 machine. I ran sudo apt-get install python-numpy command to install it and it says the package has been installed but when i try to access it, i'm unable to do so.
When you type:
sudo pip install package-name
It will default install python2 version of package-name some packages might be supported in both python3 and python3 some might work might not
I would suggest
sudo apt-get install python3-pip
sudo pip3 install MODULENAME
or can even try this
sudo apt-get install curl
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
sudo pip3 install MODULENAME
Many python packages require also the dev package, so install it too:
sudo apt-get install python3-dev
Also check for the sys.path [ make sure module is in the python path ]

How to prepare Ubuntu 14.04 for installing Django

I came across a tutorial which lists a number of libraries to install before installing Django (I am using Ubuntu 14.04, Python3, and Django 1.8):
$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get install -y build-essential
$ sudo apt-get install python-setuptools python-dev python3.4-dev python-software-properties libpq-dev
$ sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev
$ sudo apt-get build-dep python-imaging
But other tutorials may not list so many libraries to install. I wonder which are absolutely necessary, and others may be omitted?
You only need to install these dependencies if you want image processing via pillow and if you plan on installing it via pip (the Python package manager) rather than apt-get (Ubuntu's package manager).
Since you're using a virtualenv, you will need to install this package from source. The following commands will get the build dependencies and install pillow using pip.
$ sudo apt-get build-dep python3-imaging
$ pip install pillow
Note that pillow is a beast to compile. Be prepared to wait several minutes.

Unable to locate package virtualenv in ubuntu-13 on a virtual-machine

When i try to run the command:
sudo apt-get install virtualenv
The error I get in response is:
E: Unable to locate package virtualenv
The Ubuntu package is called python-virtualenv, not "virtualenv".
Try This :
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install virtualenv
It's also possible that you may not have run sudo apt-get update. It worked for me.
You need to add python before virtualenv because ubuntu package is
python-virtualenv not virtualenv.
sudo apt-get install python-virtualenv
you can install it with this instruction :
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.10.1.tar.gz
tar xvfz virtualenv-1.10.1.tar.gz
cd virtualenv-1.10.1
sudo python setup.py install
sudo apt-get update
sudo apt-get install virtualenv
Yess, if any one wants to have a look at ( installing virtualenv: a basis for the installation of ) django installation, please run this command when the shell opens up in Ubuntu:
sudo apt-get install python-setuptools
sudo apt-get install python-easy_install virtualenv
and then run the commands to simply start the instructions followed on the following link(starting from the section "Setting up a new environment"):
http://www.django-rest-framework.org/tutorial/1-serialization/

Categories