Python 3.11 - creating a virtual Env - Frozen runpy - linux

After following a thread on how to fix the pip SLL issue, now this:
So far I have spent more time fixing environments than actual training.
I am using an Oracle appliance with Linux server 7 on it.
Has anyone seen this error and know a fix for it, please?
[oracle#localhost myProjects]$ python3 -V
Python 3.11.0a4
[oracle#localhost myProjects]$ python3 -m venv env
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 148, in _get_module_details
File "<frozen runpy>", line 112, in _get_module_details
File "/usr/local/lib/python3.11/venv/__init__.py", line 7, in <module>
import logging
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/logging/__init__.py", line 26, in <module>
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/re/__init__.py", line 125, in <module>
from . import _compiler, _parser
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/re/_compiler.py", line 18, in <module>
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: SRE module mismatch

There are a couple of possible solutions on a Chinese blog platform I haven't met before. One by weixin_42424046 and one by jacke121.
Set module load apps/python/3.6.3/gnu in .bashrc, and source .bashrc after saving, but still report the same error when running python. the solution is
vi .bash_profile
Add at the end of the file
export PYTHON_HOME=/g1/app/apps/python/3.6.3/gnu/
export PATH=$PYTHON_HOME/bin:$PATH
After saving, source .bash_profile
Re-run python problem solved.
This problem is caused by the environment is 32-bit python
Change the environment to a 64 python environment
These links don't answer the exact question but can give you some ideas for further research.

Related

Setting up Hydrogen and Atom with Anaconda managing python installation

I have added my python 3 executable to the system PATH (against the advice of Anaconda) to try and get Hydrogen (and really any Atom extension/plugin) to run lines or blocks of code in Atom. The 'scripts' atom plugin appears to work (I select some code and enter ctrl-shift-b), but I'd love to use more of the features in Hydrogen. When I execute (for example):
print('hello world')
I get the following error:
Python 3
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel__init__.py", line 2, in from .connect import
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\connect.py", line 18, in import jupyter_client File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client__init__.py", line 4, in from .connect import
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 23, in import zmq
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq__init__.py", line 47, in from zmq import backend
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend__init__.py", line 40, in reraise(*exc_info)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend__init__.py", line 27, in _ns = select_backend(first)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\select.py", line 27, in select_backend mod = import(name, fromlist=public_api)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\cython__init__.py", line 6, in from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
I have reinstalled the package, I've tried using the Anaconda power shell and normal prompt to install and load Atom. My only guess is that its having trouble launching a kernel, or am I supposed to launch one and then connect?
End goal:
run code block and it works.
To use a Conda env as a kernel in Hydrogen you must register the env using ipykernel, e.g.,
conda activate myenv
python -m ipykernel install --user
This creates an entry for the kernel in a default user-level location that is generically visible to any Jupyter instances run by the user (such as Hydrogen). It is recommended to also include a --name NAME flag to distinguish your different envs. Please refer to the python -m ipykernel install -h for more options.
Also, note that the minimum requirement for using a Conda env as a kernel is to install ipykernel. And, yeah, clean up the PATH so that it conforms to Conda best practices - there should be no need for manually editing.

openslide python import show:windows error

I am using python 2.7 win 32
I need to install openslide in python
in below page show
Install openslide
http://openslide.org/download/
which item download for windows.
i tried every thing.and pip installation
the error shows below
import openslide
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import openslide
File "C:\Python27\lib\site-packages\openslide\__init__.py", line 29, in >>>> <module>
from openslide import lowlevel
File "C:\Python27\lib\site-packages\openslide\lowlevel.py", line 41, in <module>
_lib = cdll.LoadLibrary('libopenslide-0.dll')
File "C:\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
Thanks
This question may be old, but perhaps an answer will help a future viewer.
To fix this error, you need to download the openslide binaries at http://openslide.org/download/ look under (Windows Binaries)
Next, add the location of the bin folder to your system path (this will allow python to know where the module is). And that should solve the problem.
Install instructions found here: https://pypi.python.org/pypi/openslide-python

Module missing error

I have created the exe by using py2exe and this works fine in windows 8 , Application window runs without python installing. But same distribution or exe gives an error in windows 7 and windows XP. Below is the traceback for the same.
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\PySide\_utils.py", line 93, in get_pyside_dir
File "<loader>", line 10, in <module>
File "<loader>", line 8, in __load
ImportError: (DLL load failed: The specified module could not be found.) 'C:\\Users\\Test\\Desktop\\123\\dist\\PySide.QtCore.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "TopicMapParser.py", line 11, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\PySide\__init__.py", line 41, in <module>
File "C:\Python34\lib\site-packages\PySide\__init__.py", line 11, in _setupQtDirectories
File "C:\Python34\lib\site-packages\PySide\_utils.py", line 95, in get_pyside_dir
File "C:\Python34\lib\site-packages\PySide\_utils.py", line 88, in _get_win32_case_sensitive_name
File "C:\Python34\lib\site-packages\PySide\_utils.py", line 63, in _get_win32_short_name
FileNotFoundError: [WinError 3] The system cannot find the path specified.
Please help on this issue.
We are shooting into the dark when you don't post your code. So please, next time, please post your code.
Look at the errors. Python has excellent error handling and naming conventions to make it really clear on whats going wrong. It can't find the module that you are requesting. Have you attempted to update your python? To attempt to find the module that you are attempting to import? Have you double checked to make sure you did not misspell the module name? Have you searched around on stackoverflow for existing similar questions?
You are getting an ImportError and FileNotFoundError meaning it is not installed, file path is broken or you misspelled the module name.
It seems like you are trying to install QtCore, which is a package that you need to manually install using sudo apt-get install python-qt4. For windows, you have to install something that allows you to do apt-get since it is a Unix/Linux command. Try using wuinstall.
I have tried to generate the exe by using Py2exe in Python 3.4. It creates the exe and it works fine in the same machine. But it was giving an error in other machine. I have also tried with cx-freeze , still I was not able to resolve the issue. But I installed the Pyside in Python 2.7 and used py2exe for the same version and it worked nicely.
Below is the code that I have used in setup.py.
from distutils.core import setup
import py2exe
data = [('', [r'hpXMLTools.ico']), ('imageformats',[r'C:\Python34\Lib\site-packages\PySide\plugins\imageformats\qico4.dll'])]
setup(windows=[{'script': 'TopicMapParser.py',
'icon_resources': [(1, 'hpXMLTools.ico')]
}],
data_files=data,
options={
'py2exe':
{
'optimize': 2
}
}, requires=['PySide', 'xlsxwriter'])

install issue with python - spacy package in anaconda environment

I'm attempting to follow this tutorial to install the natural language processing package spaCy into a python 3 anaconda environment, windows 8
I opened console, cd-ed to my site-packages folder, activated environment, pip-ed for install, everything seemed fine except I couldn't run the second command here
$ pip install spacy
$ python -m spacy.en.download
Now I can successfully load the package but when I run the second line below, I get the following error
>>> from spacy.en import English #this works
>>> nlp = English() #this doesn't
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\garrett\Anaconda\envs\py3k\lib\site-packages\spacy\en\__init__.py", line 64, in __init__
get_lex_props=get_lex_props)
File "spacy/vocab.pyx", line 42, in spacy.vocab.Vocab.__init__ (spacy/vocab.cpp:2216)
OSError: Directory C:\Users\garrett\Anaconda\envs\py3k\lib\site-packages\spacy\en\data\vocab not found -- cannot load Vocab.
I think that it is due to the fact that I couldn't run python -m spacy.en.download
Can anyone give me an idea of what python -m spacy.en.download is supposed to be doing?
Can anyone provide a walkthrough for how to get spaCy installed in an anaconda environment?
here's the error I get after setting the directory, activating python env, running command. The first several times I tried, my spyder editor went unresponsive and I killed the console, the most recent time I got this error
$ cd C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages
$ C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages>activate py3k
$ [py3k] C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages>python -m spacy.en.download
Moving existing dir C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages\spacy\en\data to /tmp
Traceback (most recent call last):
File "C:\Users\garrett\Anaconda\envs\py3k\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Users\garrett\Anaconda\envs\py3k\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File ".\spacy\en\download.py", line 56, in <module>
plac.call(main)
File ".\plac_core.py", line 309, in call
cmd, result = parser_from(obj).consume(arglist)
File ".\plac_core.py", line 195, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File ".\spacy\en\download.py", line 51, in main
shutil.move(DEST_DIR, '/tmp')
File "C:\Users\garrett\Anaconda\envs\py3k\lib\shutil.py", line 521, in move
raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/tmp\data' already exists
appreciate any help or advice you can provide
You have hit this bug which should be already fixed in the last version. Apparently spacy can't download the data because the destination already exists (may be from a previous interrupted download). A workaround would be to delete the /temp/data folder and retry the download.

cx_freeze doesn't work in my script

I freeze a script using cx_freeze (4.3.1) in python 3.4.
The script works perfectly running in IDLE. It uses tkinter, re, and reportlab to create a pdf form.
Then the following error occurrs when I run the exe.
PS C:\Python34\build\exe.win32-3.4> .\CREEPING_cx_freeze.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "CREEPING_cx_freeze.py", line 6, in <module>
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
AttributeError: 'module' object has no attribute '_fix_up_module'
It looks like everything is working. Everything is created in the build folder, but the compiled executable does not work.
I tried searching for a solution but did not find any. Could somebody help me with this?
I´m using win 8 64 bits
Wrong version installed.
pip installs 64 bits but it doesn,t work.
running the 32bits version...works

Resources