Python 3.5 on Windows 10, 32-bit box; all I want to do is run this:
import quandl
import pandas as pd
import html5lib
import lxml
# retrieve web page with list of 50 states
fiddy_states = pd.read_html('https://simple.wikipedia.or /wiki/List_of_U.S._states')
But for the life of me I can't seem to get a properly installed lxml, which is required by pd.read_html. Following advice from several online sources I have MinGW installed in my system and I have also added the following to C:\Python35-32\Lib\distutils\distutils.cfg:
[build]
compiler=mingw32
I have MinGW installed and included in PATH. I have tried installing lxml using both pip3 as well as the binaries found at Unofficial Windows Binaries for Python Extension Packages.
Here's all installed packages:
['beautifulsoup4==4.4.1', 'cffi==1.6.0', 'cryptography==1.3.2', 'cycler==0.10.0', 'cython==0.24', 'html5lib==0.9999999', 'idna==2.1', 'inflection==0.3.1', 'lxml==3.4.4', 'matplotlib==1.5.1', 'more-itertools==2.2', 'ndg-httpsclient==0.4.0', 'numpy==1.11.0', 'pandas-datareader==0.2.1', 'pandas==0.18.1', 'pip==8.1.2', 'pyasn1==0.1.9', 'pycparser==2.14', 'pyopenssl==16.0.0', 'pyparsing==2.1.4', 'python-dateutil==2.5.3', 'pytz==2016.4', 'quandl==3.0.1', 'requests-file==1.4', 'requests==2.10.0', 'scikit-learn==0.17.1', 'setuptools==18.2', 'six==1.10.0']
As shown above, lxml==3.4.4 appears to be installed, however when I try to run the line containing pd.read_html I get the following error message:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\Jose Manuel\AppData\Local\Programs\Python\Python35-32 \lib\site-packages\pandas\io\html.py", line 874, in read_html
parse_dates, tupleize_cols, thousands, attrs, encoding)
File "C:\Users\Jose Manuel\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandas\io\html.py", line 726, in _parse
parser = _parser_dispatch(flav)
File "C:\Users\Jose Manuel\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandas\io\html.py", line 685, in _parser_dispatch
raise ImportError("lxml not found, please install it")
ImportError: lxml not found, please install itenter code here
Your help is very much appreciated
I have been struggling with this today. I found, elsewhere on stackoverflow.com, this two-part and quick solution, which resulted in python no longer complaining when I tried to use lxml:
go to this repository and download a version which matches your Python installation (the version number, and 32- vs 64-bit. I use Python 3.5.1 64-bit, installed on Windows 10, so on that page, I chose lxml-3.6.0-cp35-cp35m-win_amd64.whl. You say you have 32-bit Python, so use a version that matches that (like lxml-3.6.0-cp35-cp35m-win32.whl.
My download directory is d:\Downloads. Python must be in your PATH environment variable for the next step to work. Use a command like the following, changing "D:\Downloads" to the pathname to your download directory. Then, at a DOS prompt, type:
python -m pip install "D:\Downloads\lxml-3.6.0-cp35-cp35m-win_amd64.whl" lxml-3.6.0-cp35-cp35m-win_amd64.whl
Related
>>> import docx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\users\kevin\mu_code\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "c:\users\kevin\mu_code\docx\api.py", line 14, in <module>
from docx.package import Package
File "c:\users\kevin\mu_code\docx\package.py", line 9, in <module>
from docx.opc.package import OpcPackage
File "c:\users\kevin\mu_code\docx\opc\package.py", line 9, in <module>
from docx.opc.part import PartFactory
File "c:\users\kevin\mu_code\docx\opc\part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "c:\users\kevin\mu_code\docx\opc\oxml.py", line 12, in <module>
from lxml import etree
ImportError: cannot import name 'etree'
I have python-docx 0.8.10 and lxml 4.5.0, windows 10. I tried googling already but I'm not sure if I followed the suggestions correctly or if it's applicable in my case (lxml problems). I haven't had any problems installing other modules using "pip install" so I'm stuck and don't know how to proceed from here.
Check this,
Use pip install, to install the docx library and if you have already install it successfully then have a look into its dependencies. I think it is because of the incompatibility with its dependencies that is why you are getting the error.
pip install python-docx
Dependencies
Python 2.6, 2.7, 3.3, or 3.4
lxml >= 2.3.2
I don't know whether this may be an appropriate solution for you. But this is what I generally follow. Just install Anaconda in your system and an environment according to your needs. For your case create an environment for Python 3.4 using the following command
conda create --name py34 python=3.4
You then install libraries according to your needs in the respective environment. Now you can work into each environment without interfering with the libraries of the other environment. To use anaconda kindly follow Anaconda cheatsheet.
Kindly refer to the link. Hope this helps you.
This is almost certainly a problem with the lxml install. python-docx works with all versions of Python >= 2.6.
Instead of import docx, try from lxml import etree. If this produces the same error message, you know you've narrowed it down.
lxml depends on a couple of C libraries, lib2xml and libxslt if I remember correctly. These are sometimes tricky to install. In any case, you'll find solutions to those problems by searching on "lxml install windows" or similar.
Once from lxml import etree works without error I think you'll find import docx does too.
I have recently started using Python and have installed version 3.7.3 on my Windows 10 machine running as administrator. I then ran the following command in a command prompt to install the xmpppy package
python -m pip install xmpppy
Next I created the following base.py file that uses the aforementioned xmpppy package
#!/usr/bin/env python
import xmpp
user="user"
password="pword"
server="server"
jid = xmpp.JID(user)
connection = xmpp.Client(server,debug=[])
connection.connect()
result = connection.auth(jid.getNode(), password,"LFY-client")
connection.sendInitPresence()
while connection.Process(1):
pass
Now when I run the command
python base.py
in the folder that the base.py file exists I get the following error message:
Traceback (most recent call last):
File "base.py", line 3, in <module>
import xmpp
File "C:\Users\AGO109\AppData\Local\Programs\Python\Python37\lib\site-packages\xmpp\__init__.py", line 29, in <module>
import simplexml,protocol,debug,auth,transports,roster,dispatcher,features,browser,filetransfer,commands
ModuleNotFoundError: No module named 'simplexml'
In the folder C:\Users\AGO109\AppData\Local\Programs\Python\Python37\lib\site-packages\xmpp simplexml.py, protocol.py etc. all exist and the windows system variables contain the paths for python and packages, so what's the problem?
I'm facing same issue.
Try installing each of the packages using command like pip install simplexml and then run your code. Mine is stuck at installing transports.
Alternately,you may try switching to using sleekxmpp that comes bundled with your python installation. As sleekxmpp has latest version published in 2017 compared to that of 2006 for xmpppy, i'm planning to stick with using sleekxmpp library. If you update your code to use sleekxmpp as per the boilerplate code at https://pypi.org/project/sleekxmpp/, XMPP connections work.
Would appreciate an explanation like I'm 5 simply because I have checked all relevant answers and none have helped.
I have installed Python.
I have installed Pycharm.
I have installed Anaconda.
I have installed Microsoft Visual Studio.
I have not installed the CUDA toolkit.
In Anaconda, I used the commands mentioned on Pytorch.org (06/05/18)
conda install pytorch -c pytorch
pip3 install torchvision
Both have downloaded and installed properly, and I can find them in my Users/Anaconda3/pkgs folder, which I have added to the Python path.
Trying to enter
import torch
in the Python console proved unfruitful - always giving me the same error,
No module named 'torch'
I have also tried using the Project Interpreter to download the Pytorch package. It worked for numpy (sanity check, I suppose) but told me to go to Pytorch.org when I tried to install the "pytorch" or "torch" packages.
When trying to use the console in PyCharm, pip3 install codes (thinking maybe I need to save the packages into my current project, rather than in the Anaconda folder) return me an error message saying
torch-0.4.0-cp35-cp35m-win_amd64.whl is not a supported wheel on this
platform.
The same message shows no matter if I try downloading the CUDA version or not, or if I choose to use the 3.5 or 3.6 Python link (I have Python 3.7)
Currently the closest I have gotten to a solution, is manually copying the "torch" and "torch-0.4.0-py3.6.egg-info" folders into my current Project's lib folder.
However, when I do that and then run "import torch" I received the following error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 19, in do_import
module = self._system_import(name, *args, **kwargs) File "C:\Users\Michael\PycharmProjects\Pytorch_2\venv\lib\site-packages\torch__init__.py",
line 78, in
from torch._C import *
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 19, in do_import
module = self._system_import(name, *args, **kwargs) ModuleNotFoundError: No module named 'torch._C'
pip uninstall torch
then
pip install torch worked for me.
I encountered the same problem because I updated my python from 3.5 to 3.6 yesterday. I think the connection between Pytorch and Python is not correctly changed. Thus, I installed Pytorch for 3.6 again and the problem is solved.
Check the install command line here[1].
I am experiencing a problem when using virtualenv in openSuSE 12.3 with Python3:
I installed the python3 and python3-devel packages.
Then I installed the newest distribute and pip and finally virtualenv using pip.
When I try to create a virtualenv I get the following error:
$ virtualenv-3.3 venv01
Using base prefix '/usr'
New python executable in venv01/bin/python3.3
Also creating executable in venv01/bin/python
Installing distribute.........................................................................................................................................................................................................................................................................................................................................................................................................done.
Installing pip....
Complete output from command /home/user/venv01/bin/python3.3 -x /home/user/venv01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz:
/home/user/venv01/bin/python3.3: can't open file '/home/user/venv01/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv-3.3", line 9, in <module>
load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv-3.3')()
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1094, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 667, in install_pip
filter_stdout=_filter_setup)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1057, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/user/venv01/bin/python3.3 -x /home/user/venv01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz failed with error code 2
Running it with -vvv yields some interesting output that shows that distribute
is extracted to <venv>/local/lib/python3.3/site-packages/.
I wonder why distribute is not installed into <venv>/lib/python3.3/site-packages/?
Does anyone have an idea why this happens and how I can use virtualenv in
openSuSE without compiling python3 myself?
[now fixed in latest patches from opensuse]
[oh! i just realised you are the same person as the original link. sorry. but i will leave this as it is a top result for google search on this issue (was searching myself for any update) so it may help others.]
this is a known issue, discussed at https://forums.opensuse.org/english/get-technical-help-here/applications/484475-using-virtualenv-python-3-a.html and with an open bug at https://bugzilla.novell.com/show_bug.cgi?id=809831
the only work-around i know of is to install everything yourself. it's not so hard, and i describe what is necessary at http://www.acooke.org/cute/GettingPyt0.html
basically:
install python 3.3 from source (do an "altinstall" to install as /usr/local/bin/python3.3)
fix the lib issue (link lib_dynload from /usr/local/lib64/python3.3 to /usr/local/lib/python3.3)
install distutils
install virtualenv
then you can use python3.3 and virtual-env-3.3 etc as expected.
Recently I upgraded my Ubuntu to version 11.10 so I had to reinstall python3 modules. I downloaded latest PyQt4 but when I run configure.py I get following error:
Qt Designer plugin disabled because Python library couldn't be found
An internal error occured. Please report all the output from the program,
including the following traceback, to support#riverbankcomputing.com.
Traceback (most recent call last):
File "configure.py", line 2269, in <module>
main()
File "configure.py", line 2254, in main
subdirs=pyqt.qpy_libs() + pyqt_modules + xtra_modules + pyqt.tools(),
File "configure.py", line 957, in tools
link = "%s -lpython%d.%d%s" % (lib_dir_flag, py_major, py_minor, abi)
UnboundLocalError: local variable 'lib_dir_flag' referenced before assignment
I really haven't got a clue what is wrong. btw. Before I upgraded Ubuntu to 11.10 I used python3.1 and everything was fine.
Make sure you have the correct sip packages installed before you try to build PyQt4. For ubuntu, I think you will need the python-sip-dev and python3-sip-dev packages (plus any dependencies). Alternatively, you could download and build the latest version of sip from source.
When you run the configure.py script for either pyqt or sip, it is essential that you use the correct version of python, e.g:
/usr/bin/python3.2 configure.py