2013-05-23 17 views
5

Im abbastanza nuovo per la programmazione e Ubuntu. Ieri sono finalmente riuscito a creare un sistema dual-boot, quindi ora sto usando Ubuntu 12.04 LTS. Per un progetto scolastico, ho bisogno di lavorare in Python3 con un modulo chiamato SPARQLWrapper (https://pypi.python.org/pypi/SPARQLWrapper).Python3 non ha accesso ai moduli python2 (ubuntu)

Sul mio Ubuntu appena installato, ho installato l'ultima versione di Python. Quando digito "python3" nel mio terminale, python 3.2.3 parte così bene. Ho installato easy_install (sudo apt-get install python-setuptools), scaricato e installato il file egg SPARQLWrapper (sudo easy_install SPARQLWrapper-1.5.2-py3.2).

Se eseguo python2 e utilizzo "import SPARQLWrapper", funziona. Ma se provo lo stesso in python3 mi dà il seguente errore:

[email protected]:~$ python3 
Python 3.2.3 (default, Oct 19 2012, 20:10:41) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import SPARQLWrapper 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named SPARQLWrapper 

Quindi il mio problema è che non è in grado python3 per accedere alle stessi moduli come il mio python2. Come posso risolvere questo? Grazie!

risposta

0

Ogni installazione Python ha una propria directory di moduli. Inoltre, Python 3 non è retrocompatibile e generalmente non esegue il codice Python 2. Dovrai trovare una versione di Python 3 del modulo che ti serve e installarla per Python 3.

+0

ho già installato la versione Python 3 di questo modulo, su https://pypi.python.org/pypi/ SPARQLWrapper Ho scaricato il file SPARQLWrapper-1.5.2-py3.2.egg e l'ho installato. Questa dovrebbe essere la versione di Python3. – Bouke

8

Per installare pacchetti per Python3, hai bisogno di setuptools di python3.

Questi i passi da seguire per l'installazione di setuptools python3 e SPARQLWrapper

  1. sudo apt-get install python3-setuptools
  2. sudo easy_install3 pip
  3. pip -V Questo dovrebbe mostrare il pip corrispondente alla propria installazione python3.
  4. sudo pip install SPARQLWrapper

Dopo aver fatto la procedura di cui sopra, ho questa

~$ python3 
Python 3.3.1 (default, Apr 17 2013, 22:30:32) 
[GCC 4.7.3] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import SPARQLWrapper 
>>> exit() 
~$ 
+0

Grazie mille! Questo ha funzionato per me :) – Bouke

+0

Sul mio sistema (ubuntu 16.04) pip per python3 è invocato con "pip3" – dinosaur

Problemi correlati