Python,virtualenv,需要dist-packages来运行脚本

时间:2014-07-24 15:20:59

标签: python linux python-2.7 python-imaging-library virtualenv

Python,virtualenv和linux - noob to all 3。

我有一个小的python项目,它使用/usr/local/lib/python2.7/dist-packages内的下载包(PyFPDF)。一切正常。

我读过使用virtualenv是一个更好的方法,因为它保持项目和项目相关的包彼此分离和主要的python系统。

所以我已经设置了virtualenv,我现在有:

~/python/project/folder
                 |_py script file
                 |_folder with some project related files
                 |_env folder

$ ls env/lib/python2.7/site-packages
                            |_folder 'fpdf' & 'fpdf-1.7.2.egg-info'
                            |_others too but not not relevant here

然而,当我运行脚本时,我收到一条关于丢失PIL的消息。

我看到PIL实际上位于原始的python设置中。 /usr/lib/python2.7/dist-packages/

我的env设置根本没有dist-packages文件夹 - 链接或其他我认为是整点,即env使用通用的系统范围的python包,但允许你使用项目特定的包。

我对原始设置如何工作感到困惑,因为如上所述,我从/usr/local/lib/python2.7/dist-packages/运行,其中没有PIL。

显然,我不明白以下之间的细微差别:

/usr/local/lib/python2.7/dist-packages/(没有PIL)和

/usr/lib/python2.7/dist-packages/(有PIL)

无论如何,长期和短期是让我的项目在env中运行我在shortcut内创建了/pythonproject/env/lib/python2.7/链接到/usr/lib/python2.7/dist-packages/

脚本现在运行得很完美,但我不禁觉得我已经入侵了它,我并没有真正的精神使用virtualenv。

我希望我的描述比泥浆更清晰。正如我所说的那样,我在这3条战线上都是一个菜鸟,但我正在给它一个裂缝。希望有人可以提供帮助。

编辑:所以这些是我的命令行

user@dual-lt ~ $ cd /home/user/Documents/PyProjects/PDFproject

user@dual-lt ~/Documents/PyProjects/PDFproject $ ls env
bin  include  lib  local

user@dual-lt ~/Documents/PyProjects/PDFproject $ source env/bin/activate

(env)user@dual-lt ~/Documents/PyProjects/PDFproject $ which python
/home/user/Documents/PyProjects/PDFproject/env/bin/python

(env)user@dual-lt ~/Documents/PyProjects/PDFproject $ which pip
/home/user/Documents/PyProjects/PDFproject/env/bin/pip

(venv)user@dual-lt ~/Documents/PyProjects/PDFproject $ pip install pil
Requirement already satisfied (use --upgrade to upgrade): pil in /usr/lib/python2.7/dist-packages/PIL

Cleaning up...
(venv)user@dual-lt ~/Documents/PyProjects/PDFproject $

第二次编辑:

Downloading/unpacking pil

You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
Downloading PIL-1.1.7.tar.gz (506kB): 506kB downloaded
Running setup.py egg_info for package pil
WARNING: '' not a valid package name; please use only.-separated package names in setup.py

Installing collected packages: pil
Running setup.py install for pil
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
building '_imaging' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -IlibImaging -I/home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/include -I/usr/local/include -I/usr/include -I/usr/include/python2.7 -c _imaging.c -o build/temp.linux-x86_64-2.7/_imaging.o
_imaging.c:75:20: fatal error: Python.h: No such file or directory
#include "Python.h"
                ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Complete output from command /home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/bin/python -c "import setuptools;__file__='/home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/build/pil/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-GxHMlW-record/install-record.txt --single-version-externally-managed --install-headers /home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/include/site/python2.7:
WARNING: '' not a valid package name; please use only.-separated package names in setup.py

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying PIL/__init__.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageFile.py -> build/lib.linux-x86_64-2.7

copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageQt.py -> build/lib.linux-x86_64-2.7

copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageFileIO.py -> build/lib.linux-x86_64-2.7

copying PIL/PSDraw.py -> build/lib.linux-x86_64-2.7

copying PIL/ArgImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-2.7

copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/FontFile.py -> build/lib.linux-x86_64-2.7

copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-2.7

copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageFilter.py -> build/lib.linux-x86_64-2.7

copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageOps.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageMode.py -> build/lib.linux-x86_64-2.7

copying PIL/GdImageFile.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageCms.py -> build/lib.linux-x86_64-2.7

copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImagePalette.py -> build/lib.linux-x86_64-2.7

copying PIL/ImagePath.py -> build/lib.linux-x86_64-2.7

copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageWin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/Image.py -> build/lib.linux-x86_64-2.7

copying PIL/ExifTags.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageSequence.py -> build/lib.linux-x86_64-2.7

copying PIL/OleFileIO.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageGL.py -> build/lib.linux-x86_64-2.7

copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/PaletteFile.py -> build/lib.linux-x86_64-2.7

copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-2.7

copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageFont.py -> build/lib.linux-x86_64-2.7

copying PIL/ContainerIO.py -> build/lib.linux-x86_64-2.7

copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageGrab.py -> build/lib.linux-x86_64-2.7

copying PIL/WalImageFile.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7

copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageDraw.py -> build/lib.linux-x86_64-2.7

copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageColor.py -> build/lib.linux-x86_64-2.7

copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageMath.py -> build/lib.linux-x86_64-2.7

copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageTk.py -> build/lib.linux-x86_64-2.7

copying PIL/TiffTags.py -> build/lib.linux-x86_64-2.7

copying PIL/TarIO.py -> build/lib.linux-x86_64-2.7

copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageChops.py -> build/lib.linux-x86_64-2.7

copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageShow.py -> build/lib.linux-x86_64-2.7

copying PIL/ImageStat.py -> build/lib.linux-x86_64-2.7

copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-2.7

running build_ext

building '_imaging' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/libImaging

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -IlibImaging -I/home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/include -I/usr/local/include -I/usr/include -I/usr/include/python2.7 -c _imaging.c -o build/temp.linux-x86_64-2.7/_imaging.o

_imaging.c:75:20: fatal error: Python.h: No such file or directory

#include "Python.h"

                ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/bin/python -c "import setuptools;__file__='/home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/build/pil/setup.py'

exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-GxHMlW-record/install-record.txt --single-version-externally-managed --install-headers /home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/include/site/python2.7 failed with error code 1 in /home/dan/Documents/PyProjects/PDF-IdCardStatic/venv/build/pil

Storing complete log in /home/dan/.pip/pip.log`

0 个答案:

没有答案