I currently develop in Pycharm v4 and use Anaconda 64bit. I now need to begin using http://www.zipline.io/ which only supports Anaconda 32bit. Is there a way to have both the 32 and 64 bit versions installed and just tell Pycharm which one to use for a specific project?
Pycharm supports the creation of virtualenv environments from within the IDE, perhaps something can be done in that way? I've never used virtual environments before. Or would it be possible to just install Anaconda 32bit into it's own folder, then tell Pycharm which to use for each project.
Any advice is appreciated.
I have installed Anaconda 32 bit in a separate folder and selected this version from within Pycharm settings for the interpreter. When trying to run a basic zipline project I get the following error:
"C:\...\Anaconda3 - 32bit\python.exe" "E:/Python Projects/ZiplineTesting/Main.py"
Traceback (most recent call last):
DLL load failed: %1 is not a valid Win32 application.
File "E:/Python Projects/ZiplineTesting/Main.py", line 1, in <module>
from zipline.api import order, record, symbol
File "C:\...\AppData\Roaming\Python\Python34\site-packages\zipline\__init__.py", line 25, in <module>
from . import data
File "C:\...\AppData\Roaming\Python\Python34\site-packages\zipline\data\__init__.py", line 1, in <module>
from . import loader
File "C:\...\AppData\Roaming\Python\Python34\site-packages\zipline\data\loader.py", line 25, in <module>
import pandas as pd
File "C:\...\AppData\Roaming\Python\Python34\site-packages\pandas\__init__.py", line 7, in <module>
from . import hashtable, tslib, lib
ImportError: DLL load failed: %1 is not a valid Win32 application.
Process finished with exit code 1
It's worth noting that in my code, Pycharm has highlighted my import statement as having an error (with 'order' as well as 'record'). However there is nothing wrong with the import:
from zipline.api import order, record, symbol
The error is:
Unresolved reference 'order'
This inspection detects names that should resolve but dont.
Due to dynamic dispatch and duck typing, this is possible in a limited
but useful number of cases, Top-level and class-level items are supported
better than instance items.
Any ideas on what I might be doing incorrectly? I have tried uninstalling and reinstalling zipline which hasn't helped. It seems like there is some sort of conflict with my prior 64bit stuff with the new 32bit stuff.
In the "Settings" menu of PyCharm look for the "Project: [project name]" section. You can select the Python interpreter used for the project from there.
As long as the 32-bit version of Anaconda is installed to a separate location from the 64-bit version, there should be no problem.
Related
In my Apple M1 chip machine, trying to import panda module in IntelliJ IDEA. while running this program its giving below error.
If I run the same program in command line, it works. Running into this problem while running in the IDE.
Any help to resolve this error message?
Code
import os
import pandas as pd
Remove my home dir from this output:
Error
Traceback (most recent call last):
File "panda-test01.py", line 9, in <module>
import pandas as pd
File "Library/Python/3.8/lib/python/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "/Library/Developer/CommandLineTools/usr/bin/python3"
* The NumPy version is: "1.22.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 0x0002): tried: 'Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
Thanks
from your error message:
(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
It's a little ambiguous as it could be interpreted either way round, but I think it means that IntelliJ is running using Rosetta2 in X86 mode, whereas the numpy/pandas installation the python PATH has is your arm version. (The alternative is the reverse of this, but this way round is more likely).
In order to run your program, you'll need to create a python environment which uses Rosetta2 and installs X86 binaries instead of arm. I've written about how to do this here as a reference for myself. Then IntelliJ should have a setting somewhere to specify the python environment to use for execution and debugging, you should set that environment/PATH to your new X86 environment.
I am using Anaconda installed on Windows 10. Recently I started running into a DLL loading error when I tried to call numpy (and sometimes sklearn):
File
"C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py",
line 22, in <module>
from . import multiarray File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\multiarray.py",
line 12, in <module>
from . import overrides File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\overrides.py",
line 7, in <module>
from numpy.core._multiarray_umath import ( ImportError: DLL load failed: The specified module could not be found.
For NumPy, at least, I don't run into this issue if using jupyter notebook, started from anaconda prompt. If I tried to use another interpreter (like sublime or vs code using their conda extensions) that has been configured to look for the anaconda installation of Python, I get this error.
The thing is, "\Anaconda3\lib" doesn't exist on my machine, because on Windows, the libraries are installed in "\Anaconda3\Lib". So I have no idea why python is looking for packages in a folder that doesn't exist. In jupyter notebook (opened via anaconda prompt), the directory for packages also points to the "lib" folder, even though in that environment it doesn't seem to be a problem.
I tried starting a new environment in conda, and it still has the same issue. If anyone can explain what's going on here, I would greatly appreciate it. Is this a PATH addition issue (I didn't add an anaconda path to windows, since it's recommended by the anaconda installer)?
This question already has answers here:
How to run Python Script on powerBI
(3 answers)
Closed last year.
I currently have anaconda installed on my machine. I have a python script written which is working perfectly in Jupyter Notebook, the next step is I want to execute this script in Power BI to import data and pre-process the data.
I have adjusted the settings in powerBI (correctly I think):
Python Directory is set to C:\ProgramData\Anaconda3
Detected Python IDEs is set to Default OS program for .PY files
Can you provide a solution for the below error. I have spent hours trying to find something.
Error
Details: "ADO.NET: Python script error.
<pi>C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\pandas\__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\PROGRAMDATA\ANACONDA3\python.exe"
* The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
</pi>"
If you need to run Python scripts in Power BI and have the Anaconda stack installed, it has to be activated before you can use it. Simply open the Anaconda Prompt or run conda activate on the cmd prompt. Then start PBIDesktop from within the activated environment like:
(base) C:\> "Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe"
Make sure the Python home directory (Anaconda3) has been added to the PBIDesktop global options in the Python scripting section too.
My question is simple: can I install win32com python API (pywin32 notably) on an OS that is not Windows?
I have been trying, on Mac, multiple versions of pip install pywin32, all have failed. An example below:
If you managed to install it on Linux I am also interested as I wrote it.
I am using python 3.7.8.
Thanks.
Win32COM is part of [GitHub]: mhammond/pywin32 - pywin32. According to the (above) URL, the package is only designed to work on Win:
Python for Win32 (pywin32) extensions
So, this is Win specific (it was never intended for other OSes).
As for your question, technically you could install it on Linux, or OSX (it is possible with some manual steps), but that would make absolutely no difference, because (even if installed) it would NOT run on those platforms, as it contains (consists of) binaries (.dlls) that don't run (can't be loaded by processes) on non Win OSes.
Just looked at the comments: [MS.Docs]: Office.MessageCompose interface is available on OSX, but (most likely, if there isn't already a Python wrapper available) you'd have to write the bindings yourself (their examples are in JS).
Additional (generic) information
Some packages are only meant to work in specific conditions, based on restricting criteria like:
Platform(s) (OS, CPU architecture)
Python version(s)
...
even if not enforced by the installation mechanism (meaning they can somehow end up "installed" on platforms that they don't work on).
Anyway, such restrictions are (should be) mentioned (example for PyWin32 - see the red boxes) in package's:
PyPI page
Homepage
Other resources (e.g.: package's doc page, if it has one)
Bottom line is that such a package will not work outside the conditions it was meant to run in (even if it can be installed), and more: when attempting to run it, will yield some error message that might not be very clear.
There are packages with such restrictions, but can be installed outside them:
Win:
ComTypes
Error:
[cfati#cfati-5510-0:/mnt/e/Work/Dev/StackOverflow/q064975918]> python -c "import comtypes"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/cfati/.local/lib/python3.8/site-packages/comtypes/__init__.py", line 28, in <module>
from _ctypes import COMError
ImportError: cannot import name 'COMError' from '_ctypes' (/usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so)
Fix (improvement): [GitHub]: enthought/comtypes - Improve error message on non Win
WConio2
Error:
[cfati#cfati-5510-0:/mnt/e/Work/Dev/StackOverflow/q064975918]> python -c "import WConio2"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/cfati/.local/lib/python3.8/site-packages/WConio2.py", line 125, in <module>
from ctypes import windll
ImportError: cannot import name 'windll' from 'ctypes' (/usr/lib/python3.8/ctypes/__init__.py)
Fix (improvement): [GitHub]: Solomoriah/WConio2 - Improve error message on non Win
I'm trying to follow the instructions here to use the Boost.Python. The source code is in that webpage. I can compile, link this simple sample code but I cannot import the resulting module in python command line. It always error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named hello_ext
I have no idea what the matter is because that page just says: "That's it. We're done. We can now build this as a shared library. The resulting DLL is now visible to Python." This is my building environment:
Windows 7 64 bit, I am the Administrator and run cmd as Administrator
boost version is 1.64.0 (precompiled binary boost_1_64_0-msvc-14.0-64.exe downloaded from here)
python version is 2.7.13, 64 bit
Visual studio 2015, Update 3
The target is a DLL
The project name is ConsoleApplication1, so the output is ConsoleApplication1.dll. I have changed the filename to hello_ext.dll but same error.
I built with x64 configuration and I have verified with dumpbin that the output ConsoleApplication1.dll is really 64 bit
I have added the path ......\ConsoleApplication1\x64\Release which contains ConsoleApplication1.dll into sys.path inside python command line.
So, could you please tell me how to import the module in python? Thanks a lot.
I solved the problem myself. Thank jagerman for his useful suggestions.
(1) Just change the output filename from ConsoleApplication1.dll to hello_ext.pyd. You can automate this rename by setting Pages->General->Target Extension to ".pyd". Make sure the file hello_ext.pyd is in python's search path. You can just throw it to C:\Python27\DLLs which is one of python's built-in search paths.
(2) Now you will got a different import error: DLL load failed: The specified module could not be found. If you look closely at the file size of hello_ext.pyd, you'll likely notice something wired -- it's only 19KB. That means it doesn't contain everything needed to import into python, so python has to find the missing part to properly import it. Yes, you may guess that -- the only possible missing stuff is Boost.Python libraries, so add path to it into PATH environment variable -- for me, it is C:\local\boost_1_64_0\lib64-msvc-14.0.
Then the problem is solved. Note: some answers in other related questions may suggest build as a static library, That way, you will got another import error: DLL load failed: %1 is not a valid Win32 application. So just build as DLL. PS: you don't need to specify boost_python-vc140-mt-1_64.lib or boost_python-vc140-mt-gd-1_64.lib in Property Pages->Linker->Input->Additional Dependencies as some comments suggested.