Zauważyłem, że w skryptach Python na serwerze niemożliwe jest korzystanie z dodatkowych modułów, nawet z biblioteki standardowej, takich jak np. urllib. Czy możliwe jest odblokowanie/doinstalowanie takich modułów lub inne obejście tego problemu?
Wysłałem zapytanie w tej sprawie do naszych administratorów (QA-32072). Proszę o cierpliwość, gdy uzyskam feedback, dam znać tutaj w temacie na forum.
@_Przemek Na naszych serwerach korzystamy z Python 2.7.10 A oto lista dostępnych modułów: Code: ArgImagePlugin __future__ easy_install pwd BaseHTTPServer _abcoll ecdsa py_compile Bastion _ast email pyclbr BdfFontFile _binary encodings pydoc BmpImagePlugin _bisect ensurepip pydoc_data BufrStubImagePlugin _bsddb errno pyexpat CDROM _codecs esclient pygments CGIHTTPServer _codecs_cn exceptions pylab Canvas _codecs_hk fabfile pymysql ConfigParser _codecs_iso2022 fabric pyparsing ContainerIO _codecs_jp fcntl pytz Cookie _codecs_kr features quopri Crypto _codecs_tw filecmp random CurImagePlugin _collections fileinput re DLFCN _csv fnmatch readline DcxImagePlugin _ctypes formatter repr Dialog _ctypes_test fpformat requests DocXMLRPCServer _curses fractions resource EpsImagePlugin _curses_panel ftplib rexec ExifTags _elementtree functools rfc822 FileDialog _functools future_builtins rlcompleter FitsStubImagePlugin _hashlib gc robotparser FixTk _heapq gdbm runpy FliImagePlugin _hotshot genericpath sched FontFile _imaging getopt select FpxImagePlugin _imagingcms getpass sets GbrImagePlugin _imagingft gettext setuptools GdImageFile _imagingmath git sgmllib GifImagePlugin _imagingmorph gitdb sh GimpGradientFile _io glob sha GimpPaletteFile _json grp shelve GribStubImagePlugin _locale gzip shlex HTMLParser _lsprof hashlib shovel Hdf5StubImagePlugin _markerlib heapq shutil IN _multibytecodec hmac signal IcnsImagePlugin _multiprocessing hotshot site IcoImagePlugin _mysql htmlentitydefs six ImImagePlugin _mysql_exceptions htmllib smmap Image _osx_support httpie smtpd ImageChops _pg httplib smtplib ImageCms _pyio idlelib sndhdr ImageColor _random ihooks socket ImageDraw _socket imaplib spwd ImageDraw2 _sqlite3 imghdr sqlalchemy ImageEnhance _sre imp sqlite3 ImageFile _ssl importlib sre ImageFileIO _strptime imputil sre_compile ImageFilter _struct inspect sre_constants ImageFont _symtable io sre_parse ImageGL _sysconfigdata iotop ssl ImageGrab _testcapi itertools stat ImageMath _threading_local jinja2 statvfs ImageMode _util json string ImageMorph _warnings keyword stringold ImageOps _weakref legit stringprep ImagePalette _weakrefset lib2to3 strop ImagePath abc linecache struct ImageQt aifc linuxaudiodev subprocess ImageSequence antigravity locale sunau ImageShow anydbm logging sunaudio ImageStat argparse lxml symbol ImageTk args macpath symtable ImageTransform array macurl2path sys ImageWin arrow mailbox sysconfig ImtImagePlugin ast mailcap syslog IptcImagePlugin async markupbase tabnanny Jpeg2KImagePlugin asynchat markupsafe tarfile JpegImagePlugin asyncore marshal telnetlib JpegPresets atexit math tempfile McIdasImagePlugin audiodev matplotlib termios MicImagePlugin audioop md5 test MimeWriter base64 mhlib textwrap MpegImagePlugin bdb mimetools this MpoImagePlugin binascii mimetypes thread MspImagePlugin binhex mimify threading MySQLdb bisect mmap time OleFileIO bsddb mock timeit PIL bz2 modulefinder tkColorChooser PSDraw cPickle multifile tkCommonDialog PaletteFile cProfile multiprocessing tkFileDialog PalmImagePlugin cStringIO mutex tkFont PcdImagePlugin calendar mx tkMessageBox PcfFontFile ceph_deploy mysql tkSimpleDialog PcxImagePlugin cephclient netrc toaiff PdfImagePlugin cgi new token PixarImagePlugin cgitb nis tokenize PngImagePlugin chunk nntplib trace PpmImagePlugin clint nose traceback PsdImagePlugin cmath ntpath ttk PyAccess cmd nturl2path tty Queue code numbers turtle ScrolledText codecs numpy types SgiImagePlugin codeop opcode unicodedata SimpleDialog collections operator unittest SimpleHTTPServer colorsys optparse urllib SimpleXMLRPCServer commands os urllib2 SocketServer compileall os2emxpath urlparse SpiderImagePlugin compiler ossaudiodev user StringIO constants paramiko uu SunImagePlugin contextlib parser uuid TYPES cookielib pattern virtualenv TarIO copy pdb virtualenv_support TgaImagePlugin copy_reg pg warnings TiffImagePlugin crypt pgdb wave TiffTags csv pickle weakref Tix ctypes pickletools webbrowser Tkconstants curses pip wheel Tkdnd datetime pipes whichdb Tkinter dateutil pkg_resources wsgiref UserDict dbhash pkgutil wtforms UserList dbm platform xdrlib UserString decimal plistlib xml WalImageFile difflib popen2 xmllib WebPImagePlugin dircache poplib xmlrpclib WmfImagePlugin dis posix xxsubtype XVThumbImagePlugin distutils posixfile zipfile XbmImagePlugin django posixpath zipimport XpmImagePlugin doctest pprint zlib _LWPCookieJar dumbdbm profile _MozillaCookieJar dummy_thread pstats __builtin__ dummy_threading pty Wygląda na to, że urllib jest dostępne. Otrzymujesz komunikat błędu podczas próby skorzystania z tego modułu?
Dziękuję za odpowiedź. Nie działały mi skrypty testowe np. właśnie z tym modułem (być może powód jest inny - cenna jest informacja, że to Python 2.7), ale: Znalazłem informację, że mogę uzyskać listę dostępnych modułów za pomocą następującego skryptu: Code: import sys as s print (s.modules.keys()) po uruchomieniu na serwerze dostałem następującą listę (jest ona bardzo ograniczona i dużo mniejsza od powyższej): Code: ['copy_reg', 'sre_compile', '_sre', 'encodings', 'site', '__builtin__', 'sysconfig', '__main__', 'encodings.encodings', 'abc', 'posixpath', '_weakrefset', 'errno', 'encodings.codecs', 'sre_constants', 're', '_abcoll', 'types', '_codecs', 'encodings.__builtin__', '_warnings', 'genericpath', 'stat', 'zipimport', '_sysconfigdata', 'mpl_toolkits', 'warnings', 'UserDict', 'encodings.ascii', 'sys', 'pwd', 'codecs', 'os.path', '_locale', 'signal', 'traceback', 'linecache', 'posix', 'encodings.aliases', 'exceptions', 'sre_parse', 'os', '_weakref']
OK, dzięki bardzo za pomoc! wygląda na to, że importowanie modułów działa, a błędy były spowodowane innymi czynnikami. (prawdopodobnie różnica między Python 2.7 i 3.5)
Dlaczego na liście dostępnych modułów nie ma psycopg2? Próbuję uruchomić swoją aplikację, która komunikuje się z bazą PostgreSQL, a przez brak tego modułu mam trochę związane ręce.
Sprawdzam dostępność wskazanego modułu (QA-40570), wrócę tutaj do tematu, gdy uzyskam informacje zwrotne na ten temat. edit: @KChris informuję, że w chwili obecnej moduł psycopg2 nie jest dostępny i nie można go też zainstalować. Jest dostępny moduł o podobnym działaniu: PyGreSQL. Spróbuj skorzystać z tego drugiego przy uruchomieniu swojej aplikacji.
PyGreSQL nie można podłączyć w ustawieniach projektu jako domyślnego modułu do komunikacji z bazą, przez co staje się bezużyteczny. psycopg2 jest podstawowym modułem wykorzystywanym do komunikacji Django z PostgreSQL, dlatego jest dla mnie dużym zaskoczeniem, że nie jest on dostępny. Dodatkowo nie zapewniają Państwo bezpiecznych (szyfrowanych) połączeń do baz danych (a przynajmniej MySQL jak udało mi się sprawdzić), co niestety bardzo rozczarowuje.
A którą bibliotekę polecacie do obsługi bazy MSSQL? W zestawieniu bibliotek nie ma pyodbc ani pymssql