New to Jython.
I am this following How can I install various Python libraries in Jython? to use $ jython ez_setup.py, but ends with this error
Traceback (innermost last):
File "ez_setup.py", line 278, in ?
File "ez_setup.py", line 210, in main
File "ez_setup.py", line 139, in download_setuptools
ImportError: no module named distutils
I download ez_setup.py from here http://peak.telecommunity.com/dist/ez_setup.py. I have installed jython correct under the guidance from here http://www.jython.org/archive/22/installation.html
Thank you guys in advance.
It appears that distutils is not available in your version of Jython. From the link you provided, it looks like you are using Jython2.2, and when I start Jython2.2.1 and try to import distutils, I also get an ImportError:
Jython 2.2.1 on java1.7.0_79
Type "copyright", "credits" or "license" for more information.
>>> import distutils
Traceback (innermost last):
File "<console>", line 1, in ?
ImportError: no module named distutils
>>>
On a more recent version of Jython, the distutils module imports successfully:
Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_60
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>>
Is there a reason you must such an old version of Jython?
Related
I installed Anaconda and activated the environment. When I attempt to run a python script which imports numpy in Visual Studio Code I am facing the following error:
(base) C:\Users\UserX\python test.py
ModuleNotFoundError: No module named 'numpy.core'; 'numpy' is not a package
Traceback (most recent call last):
File "test.py", line 1, in <module>
import numpy
File "C:\Users\UserX\numpy.py", line 2, in <module>
import matplotlib
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 174, in <module>
_check_versions()
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 159, in _check_versions
from . import ft2font
ImportError: numpy.core.multiarray failed to import
I have no issues with running the same directly:
(base) C:\Users\python
Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
Conda info confirms the same python version in use...
(base) C:\Users\UserX\conda info
active environment : base
active env location : C:\ProgramData\Anaconda3
shell level : 1
user config file : C:\Users\UserX\.condarc
populated config files : C:\Users\UserX\.condarc
conda version : 4.9.2
conda-build version : 3.20.5
python version : 3.8.5.final.0
the chosen python interpreter is the one installed with Anaconda and no other version of python exists.
C:\ProgramData\Anaconda3
I tried reinstalling numpy, matplotlib, Anaconda, Visual Studio Code, deleting Anaconda directory and any other potential solutions I could found with a search engine. Is there anything obvious I am missing here?
Actually, I missed an important fact that another file within the same directory had a name numpy.py which was causing issues as per the error message. Oh boy... I should have noticed that earlier. I have renamed the file and the issue is resolved.
File "C:\Users\UserX\numpy.py", line 2, in <module>
I'm trying to develop software using Jython and SOCKS5, so I installed PySocks, but I'm receiving the following import error:
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> import socks
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socks.py", line 117, in <module>
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
How can I correctly use PySocks in Jython?
“The Jython project strives to make all Python modules run on the JVM, but there are a few differences between the implementations. Perhaps the major difference between the two implementations is that Jython does not work with C extensions. Therefore, most of the Python modules will run without changes under Jython, but if they use C extensions then they will probably not work.”
According to the jython doc, it seems jython doesn't support C entensions.
you can install this lib by this cmd:
# sudo apt-get install python-socksipy
I found the response in :
How do I install Socks / SocksIPy on Ubuntu?
Trying to use the rpy2.ipython (formerly 'rmagic') extension of IPython, to get interactive R (%R line magic and %%R cell magic functions), I get the following errors...
louis ~ $ python
Python 3.5.1 |Anaconda 2.4.0 (64-bit)| (default, Dec 7 2015, 11:16:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.ipython
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
File "pandas/src/numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:38262)
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 20, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/__init__.py", line 51, in <module>
from .linalg import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 59, in <module>
from rpy2.robjects import pandas2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/pandas2ri.py", line 6, in <module>
from pandas.core.frame import DataFrame as PandasDataFrame
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_ not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 63, in <module>
from rpy2.robjects import numpy2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/numpy2ri.py", line 6, in <module>
import numpy
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 13, in <module>
import numpy.core.numeric as NX
AttributeError: module 'numpy' has no attribute 'core'
I've always ignored the fact that Anaconda3 seems to have been built on RHEL (I'm on Linux Mint, which is based on Ubuntu), but I'm wondering now if this might be the cause of the problem here - "C extensions not built" for my machine?
Since it's in the conda virtual environment, I'm not sure how I can fix this.
Should I attempt to python setup.py build_ext --inplace within ~/anaconda3/lib/python3.5/site-packages/pandas ?
When I step through the above imports, of e.g. :
from numpy.linalg import lapack_lite, _umath_linalg
there's no error, so I'm not certain there are actually unbuilt files, perhaps it's just some masking of one variable by another (as in this question with similar error message but different traceback, i.e. an error in rpy2).
import numpy.core (etc.) without first trying to load rpy2.ipython works fine
Summary of pip show :
---
Metadata-Version: 2.0
Name: rpy2
Version: 2.7.5
---
Metadata-Version: 1.1
Name: numpy
Version: 1.10.1
---
Metadata-Version: 1.1
Name: pandas
Version: 0.17.0
---
Metadata-Version: 2.0
Name: ipython
Version: 4.0.1
(all locations /home/louis/anaconda3/lib/python3.5/site-packages)
System info from cat /proc/version and lsb_release -a :
Linux version 3.13.0-35-generic (buildd#panlong) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch
Description: Linux Mint 17 Qiana
I am suspecting an incompatibility between versions of the LAPACK library: the one picked at runtime on your system, the one numpy was built with, and the one R was built with.
Installing numpy, R, and rpy2 from source in your virtual environment should solve the issue. An alternative would be to notify the maintainers of the anaconda packages involved and see it they confirm that numpy and R packaged by anaconda use the same LAPACK.
I recieved an error after the installation of pythonxy, as far as I know pythonxy including numpy and scipy, however I can't import these features on the command prompt.
How can I deal this problem ?
Here is my error message, thank you stackoverflow community.
C:\WINDOWS\system32>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'scipy'
Python(x,y) installs Python 2.7. It seems that you have started Python 3. The discussion in How to run different python versions in cmd might help.
I have followed all of the steps on http://steamforge.net/wiki/index.php/How_to_Install_Scrapy_in_64-bit_Windows_7 , but cannot seem to import scrapy to start working with it. I have installed basically every dependent program at least twice at this point, including pywin32. Every time I start up python and attempt to import scrapy, I get a "No module named twisted" error message.
EDIT:Robin, I am pretty sure twisted is installed correctly, but I don't know how to select which environment it uses; only the python 2.7 environment pops up as an option when I try to install twisted, but I also have anaconda installed.
I have tried importing twisted from both command line interfaces. In anaconda, it is able to find the scrapy when I import it, but cannot then find twisted.
When I attempt to open scrapy in python2.7, it just says no module named scrapy. However, when I try to import twisted it works just fine.
I think everything would be ok if I could get one or the other into the opposite folder, but I don't know how to do that.
Jean-Paul, the full path for python2.7 is C:\python27\python.exe ; the full path for anaconda is: C:\anaconda\python.exe
the import Scrapy traceback is:
C:\Anaconda>python
Python 2.7.5 |Anaconda 1.8.0 (64-bit)| (default, Jul 1 2013, 12:37:52) [MSC v.1
500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import scrapy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\scrapy-0.22.0-py2.7.egg\scrapy\__init__.py
", line 43, in <module>
from twisted import version as _txv
ImportError: No module named twisted
>>> import easy_install
>>> easy_install scrapy
File "<stdin>", line 1
easy_install scrapy
^
SyntaxError: invalid syntax
>>>
and the traceback in python2.7 is:
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrapy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scrapy
>>>
I hope that is enough, I would give you all of the files that were installed when twisted was, but I have no idea how to give you a list like that. Thanks for the help, and sorry for being a n00b.