I have a python script for auto mailing when there is a commit in svn, but when i run the script it gives following error :
Traceback (most recent call last):
File "E:\AutoSms-Svn-Repo\test-repo-is\hooks\mailer.py", line 41, in <module>
import svn.fs
File "C:\Python25\Lib\site-packages\svn\fs.py", line 19, in <module>
from libsvn.fs import *
File "C:\Python25\Lib\site-packages\libsvn\fs.py", line 5, in <module>
import _fs
ImportError: DLL load failed: The specified module could not be found.
I even added required path variables for dependent dlls and python path
but still i get this message, even from command prompt
Thanks in advance
I got the same problem instaling subversion under Windows 7 for Python 2.7.
The solution is simple and has been tested. (but hard work to find and analize)
Download and install binaries from Subversion
Make sure thet binaries folder (default: c:\Program Files (x86)\subversion\bin) is in your PATH system
Download Python files from site mentioned in point 1 ( Subversion )
Extract libsvn and svn into Python's site-packages folder
Open cmd (Window's command line console) and type: python. Then try to import svn module.
It should looks like (no error occured):
C:\>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from svn import core
>>>
Related
I want to install a package called Xsequence https://github.com/fscarlier/xsequence
in Windows vie git clone command and then I used python to install it
git clone https://github.com/fscarlier/xsequence.git
cd xsequence_master
python setup.py install
I have several python versions installed, put the one that was used in the installation was in the first path.
C:\Users\musa\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\musa\Anaconda3\python.exe
C:\Users\musa\AppData\Local\Microsoft\WindowsApps\python.exe
The issue is that when I import the package Xsequence it works fine,
But when I try to import any other module from inside this package it doesn't work
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xsequence
>>> from xsequence.lattice import Lattice
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\musa\AppData\Local\Programs\Python\Python310\lib\site-packages\xsequence-0.0.0-py3.10.egg\xsequence\lattice.py", line 11, in <module>
File "C:\Users\musa\AppData\Local\Programs\Python\Python310\lib\site-packages\xsequence-0.0.0-py3.10.egg\xsequence\elements.py", line 13, in <module>
ModuleNotFoundError: No module named 'xsequence.helpers'
I checked the package folder manually it contains the module Xsequence.helper.
The strange thing that all the module can be imported if I run python directly after instilling the setp.py but once I closed the terminal its not imported anymore
Please note that I am using pure Python and not something like Anaconda. Running on a new, updated Windows 10 machine with no virtual environment. After removing all previous Python installations, rebooting and performing a fresh install if Python 3.9.1. I run the python console and type:
import sqlite3
I receive the following error:
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import sqlite3
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\Python39\lib\sqlite3_init_.py", line 23, in
from sqlite3.dbapi2 import *
File "C:\Program Files\Python39\lib\sqlite3\dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: DLL load failed while importing _sqlite3: The specified module could not be found.
I verified that the sqlite3.dll file does exist in C:\Program Files\Python39\DLLs
It was an environment issue. Previous builds (using Kivy) had left .pyd and .pyc files in the application directory and when we ran the application, python would try to load those and the files they reference, rather than using the proper files in the Python39 directory. As soon as we deleted those artifacts, the app ran fine (and sqlite loaded fine).
This is presumably the same as Python produces: OSError: [WinError 193] %1 is not a valid Win32 application However, that has no answers, and I have additional details for my situation.
Background:
I'm using a venv, it gets activated internally with activate_this.py via:
exec(compile(open(venv_script, "rb").read(), venv_script, 'exec'), dict(__file__=venv_script))
This worked on python2 at least...
when I import numpy I get:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\core\__init__.py", line 23, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Python37\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
If I activate the venv normally, I can import numpy fine, so I'm guessing the problem is how I'm using activate_this.py...
Minimal case:
C:\Dropbox (CEP)\venvs>virtualenv testEnv
Using base prefix 'c:\\users\\brianp\\appdata\\local\\programs\\python\\python37-32'
New python executable in C:\DROPBO~1\venvs\testEnv\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
C:\Dropbox (CEP)\venvs>testEnv\Scripts\activate
(testEnv) C:\Dropbox (CEP)\venvs>pip install numpy
Collecting numpy
Using cached https://files.pythonhosted.org/packages/61/be/b4d697563d4a211596a350414a87612204a8bb987c4c1b34598cd4904f55/numpy-1.16.2-cp37-cp37m-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.16.2
(testEnv) C:\Dropbox (CEP)\venvs>deactivate
C:\Dropbox (CEP)\venvs>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> this_file = 'testenv/Scripts/activate_this.py'
>>> exec(open(this_file).read(), {'__file__': this_file})
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Dropbox (CEP)\venvs\testenv\Lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Dropbox (CEP)\venvs\testenv\Lib\site-packages\numpy\core\__init__.py", line 23, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Python37\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
>>> exit()
C:\Dropbox (CEP)\venvs>testEnv\Scripts\activate
(testEnv) C:\Dropbox (CEP)\venvs>python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
This is a well known error: it's an architecture mismatch 032bit / 064bit (pc032 / pc064), in your case trying to load a 032bit .dll in a 064bit process. To make things clear, NumPy contains a bunch of .dlls that get loaded in the current process when importing it.
It's actually a duplicate of [SO]: Python Ctypes - loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application (#CristiFati's answer), but I'm going to detail.
The examples in the question are twisted and hard to read: some example that works, then some that doesn't then some that works again and so on (for example I don't even know what's the 2nd snippet purpose), instead of clearly separating scenarios that do work from those that don't.
Anyway in spite of the above, I was able to identify the problem.
The testEnv environment that you created (and installed NumPy in) is pc032:
3rd snippet (begin):
Using base prefix
'c:\\users\\brianp\\appdata\\local\\programs\\python\\python37-32'
3rd snippet (end):
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
In this case, import numpy works (and NumPy (and the .dlls that it contains) is pc032)
The Python interpreter launched from outside testEnv is pc064:
3rd snippet (mid):
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
When running testEnv's activate_this.py in the current process, it adds testEnv paths to %PYTHONPATH% (sys.path), and import numpy picks the pc032 version from testEnv, which obviously fails
To get rid of this error you can either (listing some of the possible options):
Use a pc032 Python from outside VEnv (C:\Dropbox (CEP)\venvs\python)
The other way around: create a testEnv64 VEnv, and use its activate_this.py
Don't use activate_this.py at all, unless you know what you're doing (I'd recommend this one)
Might also want to check [SO]: PyCharm doesn't recognize installed module (#CristiFati's answer).
Another thing might have happened. VS code automatically searches for the numpy and other packages from predefined OS locations. It might have found out 32 bit version of numpy instead of a 64 bit version.
Fix:
Uninstall numpy from all OS locations
* In VS code terminal. Type pip uninstall numpy or conda uninstall numpy (If you use Anaconda)
* Restart VS code
* Voila! (Reinstall numpy if the problem persists)
I have installed mechanize library for python3.
https://github.com/adevore/mechanize/tree/python3
But, when I import it, I get this error.
Python 3.3.3 (default, Dec 30 2013, 16:15:14)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import mechanize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/__init__.py", line 122, in <module>
File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_mechanize.py", line 15, in <module>
File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_html.py", line 16, in <module>
ImportError: cannot import name _sgmllib_copy
But, I'm sure that mechanize is installed in the same virtualenv directory.
$ pip freeze
## FIXME: could not find svn URL in dependency_links for this package:
mechanize==0.2.6.dev-20140305
pyquery==1.2.8
Warning: cannot find svn location for mechanize==0.2.6.dev-20140305
I'm not used to operation in terminal, so I don't know how to fix this problem.
Could anyone please help me solve this problem?
Thank you in advance!
The git repository you referred to uses import wrong. The mechanize._html module imports _sgmllib_copy expecting to get mechanize._sgmllib_copy, but that way of doing imports has been deprecated in PEP 328. Rather it should be using relative imports, e.g. from . import _sgmllib_copy.
https://github.com/adevore/mechanize/tree/python3
This branch doesn't contain _sgmllib_copy.py at all. I took this file from master branch (it needs to change print smth to print (smth)). But I still don't get how import should be used. In _html.py module (it's located in mechanize folder) used
from . import _sgmllib_copy as sgmllib
Is this wrong? But from . import _beautifulsoup seems to be working.
I have Redhawk 1.9 loaded on a 32-bit CentOS 5 virtual machine. I am trying to run the Redhawk HelloWorld component described here: http://redhawksdr.github.io/Documentation/mainch3.html. I am able to launch and start the component in the eclipse sandbox. I cannot run it from Python though. I get the following error.
Python 2.7.2 (default, Feb 27 2012, 16:40:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ossie.utils import sb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/redhawk/core/lib/python/ossie/utils/sb/__init__.py", line 115, in <module>
from domainless import *
File "/usr/local/redhawk/core/lib/python/ossie/utils/sb/domainless.py", line 102, in <module>
from omniORB import CORBA, any
ImportError: No module named omniORB
>>>
Any ideas why it will not work?
You'll probably have to set your PYTHONPATH manually to include the appropriate directory. It looks like Eclipse is doing that for you.
Try running your example as root. If you can successfully run as root, then you have a permission problem on your directories or files. How do you identify the files that have the incorrect permission ? I ran the following command,
strace -o test.out python -c "from ossie.utils import sb"
This command will write the output to test.out. Look for the string "denied", which will identify the file that has the incorrect file permission.