i am using python 2.7.11 on virtualenv in lubuntu 12.04.(dont own a good laptop its dell latitude d600)
Python 2.7.11 (default, Mar 4 2016, 04:38:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import sqlite3
Traceback (most recent call last):
File "", line 1, in
File "/home/maharshi/.localpython/lib/python2.7/sqlite3/init.py", line 24, in
from dbapi2 import *
File "/home/maharshi/.localpython/lib/python2.7/sqlite3/dbapi2.py", line 28, in
from _sqlite3 import *
ImportError: No module named _sqlite3
i have installed pysqlite using pip and it says successfull.
(p2.7) maharshi#maharshi-Latitude-D600:~/code$ which python
/home/maharshi/virtualenvs/p2.7/bin/python
(p2.7) maharshi#maharshi-Latitude-D600:~/code$ which pip
/home/maharshi/virtualenvs/p2.7/bin/pip
(p2.7) maharshi#maharshi-Latitude-D600:~/code$ pip install pysqlite
Requirement already satisfied (use --upgrade to upgrade): pysqlite in /home/maharshi/virtualenvs/p2.7/lib/python2.7/site-packages
i also installed it manually at both locations i.e
~/virtualenvs/p2.7/
~/.localpython/ (from where i created the virtualenv)
i also installed "libsqlite3-dev(as suggested by one of the posts)" i.e
sudo apt-get install libsqlite3-dev
Thank you in advance.
Try doing the whole process again installing python in virtualenv...as i understand when you add the libraries needed for SqlLite it wont affect the virtualenv python so you have to re-do all the steps and it will compile with the required libraries....
Related
This used to work but I don't know what changed; nothing has changed in this repo for a while.
I have a local python package that I want to install via pip. My source tree looks like:
./local_packages/my-package-0.0.3.tar.gz
and my requirements.txt has only
my-package
I run
pip install --find-links="./local_packages" --target=./python_modules/ -r requirements.txt
This finds my package and installs it in python_modules but I can't import it:
Python 3.6.7 (default, Nov 30 2020, 14:15:49)
[GCC Apple LLVM 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from my_package import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'my_package'
When I look in python_modules I see all of the dependencies of my-package as well as my_package-0.0.3-py3.6.egg-info/ but there is no module for just my_package.
If I downgrade pip from 20.3 to 19.3.1, then I see what I was expecting, with both a folder for .egg-info as well as for the module itself. My import works correctly etc.
Is this expected behavior? Am I missing something?
why it does not work? Django.tar.gz is straight from PyPi
if i try "python -m pip install" it works, but installs python globally.
(newenv) [root]# pip install paczki/Django-2.0.7.tar.gz
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Processing ./paczki/Django-2.0.7.tar.gz
Requirement already satisfied: pytz in ./newenv/lib/python3.6/site-packages (from Django==2.0.7)
Installing collected packages: Django
Running setup.py install for Django ... done
Successfully installed Django-2.0.7
(newenv) [root]# python3
Python 3.6.0 (default, May 22 2018, 12:59:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
>>>
Figured this out. There was an systemwide alias set earlier by someone, which aliased python to a specific path like "/A/B/python", thus even while in venv used python was this one. :which python: might be misleading - id DOES NOT check for aliases, so :which python: and :python: did not pointed to the same one.
I use Python 3.5 and I have installed cloudant package by an execute command:
sudo -H pip3 install cloudant
I try to connect with python database. According to the documentation - https://console.bluemix.net/docs/services/Cloudant/getting-started.html#getting-started-with-cloudant. This code should works:
from cloudant.client import Cloudant
client = Cloudant("username", "password", url="https://user_name.cloudant.com")
client.connect()
client.disconnect()
When I run it I get an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tomek/Projects/stage-control/cloudant.py", line 1, in <module>
from cloudant.client import Cloudant
ImportError: No module named 'cloudant.client'; 'cloudant' is not a package
I suspect your problem may be that the pip used to install the module isn't the pip that your python is using:
If I do pip3 install cloudant I get the same problem as you:
(py35) stefans-mbp:work stefan$ python
Python 3.5.3 |Anaconda 4.4.0 (x86_64)| (default, Mar 6 2017, 12:15:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cloudant.client import Cloudant
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'cloudant.client'
This is because of this:
(py35) stefans-mbp:work stefan$ which pip
//anaconda/envs/py35/bin/pip
(py35) stefans-mbp:work stefan$ which pip3
/usr/local/bin/pip3
The wrong pip3 was used to install the cloudant module. To remedy, ensure you use the pip in the virtual env you're using:
(py35) stefans-mbp:work stefan$ pip install cloudant
Collecting cloudant
Using cached cloudant-2.7.0.tar.gz
Requirement already satisfied: requests<3.0.0,>=2.7.0 in
/anaconda/envs/py35/lib/python3.5/site-packages (from cloudant)
Building wheels for collected packages: cloudant
Running setup.py bdist_wheel for cloudant ... done
Stored in directory: ...
Successfully built cloudant
Installing collected packages: cloudant
Successfully installed cloudant-2.7.0
Now it works:
(py35) stefans-mbp:work stefan$ python
Python 3.5.3 |Anaconda 4.4.0 (x86_64)| (default, Mar 6 2017, 12:15:08)
Type "help", "copyright", "credits" or "license" for more information.
>>> from cloudant.client import Cloudant
>>>
Just rename your file cloudant.py to something else.
Are you running locally or in an app on Bluemix? There must be something wrong with your install, because the code looks fine. This code runs for me:
from cloudant.client import Cloudant
from cloudant.document import Document
client = Cloudant("username", "pw", url="https://username.cloudant.com")
client.connect()
thedb = client["databasename"]
for document in thedb:
print(document)
client.disconnect()
If you're running on Bluemix, make sure you have a requirements.txt file to trigger library imports. See https://pip.readthedocs.io/en/1.1/requirements.html
I have tried to re-install and got the following message:
Requirement already satisfied: troposphere==1.8.2 in /usr/local/lib/python2.7/site-packages (from -r requirements.txt (line 13)
I checked my python version and I could see this as same:
animjain$ python -V
Python 2.7.10
When I try to import a module, get the following error:
animjain$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from troposphere import Join, Ref, FindInMap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named troposphere
You should use virtualenv to install dependencies for your project. You don't need to clog global site-packages.
For example:
sudo apt-get install virtualenv
cd ~
virtualenv your_test_venv
source your_test_venv/bin/activate
pip install troposphere
After that you can use your new package.
When you want to deactivate your virtualenv you can run command deactivate
In case you have multiple Python versions on your machine, install with the same Python command, so instead of:
animjain$ pip install troposphere==1.8.2
run:
animjain$ python -mpip install troposphere==1.8.2
I wrote a command line tool with cliff 2.3.0, tested on my laptop (Mac, Python 2.7.12). When I was tried to install it (python setup.py install) on a server (Linux, Python 2.7.2), I encountered this error:
Installed /private/tmp/easy_install-EGMO15/cliff-2.3.0/pbr-1.10.0-py2.7.egg
ERROR:root:Error parsing
Traceback (most recent call last): File "/private/tmp/easy_install-EGMO15/cliff-2.3.0/pbr-1.10.0-> py2.7.egg/pbr/core.py", line 111, in pbr
attrs = util.cfg_to_args(path, dist.script_args) File "/private/tmp/easy_install-EGMO15/cliff-2.3.0/pbr-1.10.0-py2.7.egg/pbr/util.py", line 248, in cfg_to_args
kwargs = setup_cfg_to_setup_kwargs(config, script_args) File "/private/tmp/easy_install-EGMO15/cliff-2.3.0/pbr-1.10.0-py2.7.egg/pbr/util.py", line 431, in setup_cfg_to_setup_kwargs
if pkg_resources.evaluate_marker('(%s)' % env_marker):
AttributeError: 'module' object has no attribute 'evaluate_marker' error: Setup script exited with error in setup command: Error parsing /private/tmp/easy_install-EGMO15/cliff-2.3.0/setup.cfg: AttributeError: 'module' object has no attribute 'evaluate_marker'
Any suggestions?
It looks like your server may have a (much) older version of the setuptools package installed (which provides the pkg_resources module). The evaluate_marker method looks as if it first showed up at the end of 2014, so if you're using an older system it is possible that method is not available.
Depending on your environment, you may be able to simply pip install -U setuptools, or you may need to see if your distribution has a newer isntallable package available.
If you can update your question to include details about your server's operating environment (what distribution and version are you running? What version of Python? What version of setuptools?), we can probably provide a more complete answer.
Update
For example, Ubuntu 12.04 only has setuptools 0.6, and the pkg_resources module (which is packaged in the python-pkg-resources package) does not have the evaluate_marker method:
# python
Python 2.7.3 (default, Jun 22 2015, 19:33:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> pkg_resources.evaluate_marker
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'evaluate_marker'
In this environment, I can install pip:
# apt-get install python-pip
And then upgrade the installed version of setuptools:
# pip install -U setuptools
And now:
# python
Python 2.7.3 (default, Jun 22 2015, 19:33:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> pkg_resources.evaluate_marker
<function evaluate_marker at 0x1535050>
>>>
NB Upgrading distribution packages (e.g., things installed by apt-get in this example) using pip can often lead to sadness and heartache, and you are much better off if you are able to upgrade the underlying environment to one where such workarounds are not necessary. Alternatively, running your code from a Python virtual environment (so that your upgraded packages do not override system packages) is also a technically better solution.