Environment
Pythonnet version: 2.4.0.dev0, installed from Master
Python version: Python 3.6.6, Anaconda 3
Operating System: Window 10, 64 bit
Using virtual studio 2017 Community
Details
I had virtual environment set up.
1) pip list
(py36) C:\Users\User\Desktop>pip list
Package Version
--------------- ----------
certifi 2018.8.13
click 6.7
cycler 0.10.0
kiwisolver 1.0.1
matplotlib 2.2.3
mkl-fft 1.0.4
mkl-random 1.0.1
numpy 1.15.0
Pillow 5.2.0
pip 18.0
pyparsing 2.2.0
PyQt5 5.11.2
PyQt5-sip 4.19.12
python-dateutil 2.7.3
pythonnet 2.4.0.dev0
pytz 2018.5
scipy 1.1.0
setuptools 40.0.0
six 1.11.0
visbrain 0.4.2
vispy 0.5.3
wheel 0.31.1
wincertstore 0.2
2) path and pythonpath before python initialize.
string path = #"D:\Anaconda3\envs\py36;" + Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
Environment.SetEnvironmentVariable("PATH", path, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONHOME", #"D:\Anaconda3\envs\py36", EnvironmentVariableTarget.Process);
// initialize python engine
PythonEngine.Initialize();
3) set Amaconda in %PATH%
4) python path
(py36) C:\Users\User\Desktop>python --version
Python 3.6.6 :: Anaconda, Inc.
ReadMe works fine.
but when i typed like this in my C# program
using (Py.GIL())
{
// import vispy
dynamic myVispy = Py.Import("vispy");
Console.WriteLine("hi vispy");
}
error message below
Python.Runtime.PythonException: 'ModuleNotFoundError : No module named 'vispy''
stack trace :
Python.Runtime.PythonException
HResult=0x80131500
Message=ModuleNotFoundError : No module named 'vispy'
Source=Python.Runtime
StackTrace:
would like to know how to solve this ?
Thank You.
See this answer: Python.NET does not work with Anaconda or Miniconda. You need a fresh python install.
Related
I have create this simple env with conda:
conda create -n test python=3.8.5 pandas scipy numpy matplotlib seaborn jupyterlab
The following code in jupyter lab crashes the kernel :
import matplotlib.pyplot as plt
plt.subplot()
I don't face the problem on Linux. The problem is when I try on Windows 10.
There are no errors on the jupyter lab console (where I started the server), and I have no idea where to investigate.
Update 2021-11-06
The default pkgs/main channel for conda has reverted to using freetype 2.10.4 for Windows, per main / packages / freetype.
If you are still experiencing the issue, use conda list freetype to check the version: freetype != 2.11.0
If it is 2.11.0, then change the version, per the solution, or conda update --all (providing your default channel isn't changed in the .condarc config file).
Solution
If this is occurring after installing Anaconda, updating conda or freetype since Oct 27, 2021.
Go to the Anaconda prompt and downgrade freetype 2.11.0 in any affected environment.
conda install freetype=2.10.4
Relevant to any package using matplotlib and any IDE
For example, pandas.DataFrame.plot and seaborn
Jupyter, Spyder, VSCode, PyCharm, command line.
Discovery
An issue occurs after updating with the most current updates from conda, released Friday, Oct 29.
After updating with conda update --all, there's an issue with anything related to matplotlib in any IDE (not just Jupyter).
I tested this in JupyterLab, PyCharm, and python from the command prompt.
PyCharm: Process finished with exit code -1073741819
JupyterLab: kernel just restarts and there are no associated errors or Traceback
command prompt: a blank interactive matplotlib window will appear briefly, and then a new command line appears.
The issue seems to be with conda update --all in (base), then any plot API that uses matplotlib (e.g. seaborn and pandas.DataFrame.plot) kills the kernel in any environment.
I had to reinstall Anaconda, but do not do an update of (base), then my other environments worked.
I have not figured out what specifically is causing the issue.
I tested the issue with python 3.8.12 and python 3.9.7
Current Testing:
Following is the conda revision log.
Prior to conda update --all this environment was working, but after the updates, plotting with matplotlib crashes the python kernel
2021-10-31 10:47:22 (rev 3)
bokeh {2.3.3 (defaults/win-64) -> 2.4.1 (defaults/win-64)}
click {8.0.1 (defaults/noarch) -> 8.0.3 (defaults/noarch)}
filelock {3.0.12 (defaults/noarch) -> 3.3.1 (defaults/noarch)}
freetype {2.10.4 (defaults/win-64) -> 2.11.0 (defaults/win-64)}
imagecodecs {2021.6.8 (defaults/win-64) -> 2021.8.26 (defaults/win-64)}
joblib {1.0.1 (defaults/noarch) -> 1.1.0 (defaults/noarch)}
lerc {2.2.1 (defaults/win-64) -> 3.0 (defaults/win-64)}
more-itertools {8.8.0 (defaults/noarch) -> 8.10.0 (defaults/noarch)}
pyopenssl {20.0.1 (defaults/noarch) -> 21.0.0 (defaults/noarch)}
scikit-learn {0.24.2 (defaults/win-64) -> 1.0.1 (defaults/win-64)}
statsmodels {0.12.2 (defaults/win-64) -> 0.13.0 (defaults/win-64)}
sympy {1.8 (defaults/win-64) -> 1.9 (defaults/win-64)}
tqdm {4.62.2 (defaults/noarch) -> 4.62.3 (defaults/noarch)}
xlwings {0.24.7 (defaults/win-64) -> 0.24.9 (defaults/win-64)}
The issue seems to be freetype
Downgrading from 2.11.0 to 2.10.4 resolved the issue and made the environment work with matplotlib
Went to post a bug report and discovered there is [Bug]: Matplotlib crashes Python #21511
For anybody that downgrading to freetype=2.10.4 didn't work. In my case the issue happened after installing the new version of scikit-learn=1.11 from conda-forge channel. After trying out many options the following worked for me:
reinstall numpy from main/pkg to conda-forge channel
reinstall mkl package conda -c intel mkl
reinstall matplotlib=4.3 from conda-forge
It's quite a drastic measure, since you have to reinstall all dependecies that rely on NumPy (Pandas, TensorFlow etc.), but it was the only one that worked for me.
I had the same issue and after a fair amount of investigation and troubleshooting, the fix was pretty straight forward:
conda update -c anaconda numpy
conda upgrade -c conda-forge matplotlib
After that it ran fine and my visuals plotted without issue.
I am working with a Python virtualenv named env to execute Odoo. In the virtualenv bin directory, I got this:
pip
pip3
pip3.8
python -> /usr/bin/python3
python3 -> python
python3.8 -> python
And the Odoo service is running this command to execute Odoo (as you can see, using the python3.8 of the virtualenv):
ExecStart=/opt/odoo/env/bin/python3.8 /opt/odoo/odoo_13/src/oca/OCB/odoo-bin -c /opt/odoo/odoo_13/config/.odoo.conf
The problem is that every now and again, Odoo gives the following critical error and the instance stops working:
ModuleNotFoundError: No module named 'werkzeug'
It seems that the werkzeug package is not installed, but, if I do the following:
anubia#my-server:/opt/odoo$ . env/bin/activate
(env) anubia#my-server:/opt/odoo$ which pip
/opt/odoo/env/bin/pip
(env) anubia#my-server:/opt/odoo$ which pip3
/opt/odoo/env/bin/pip3
(env) anubia#my-server:/opt/odoo$ which pip3.8
/opt/odoo/env/bin/pip3.8
(env) anubia#my-server:/opt/odoo$ pip3.8 install werkzeug
Requirement already satisfied: werkzeug in ./env/lib/python3.8/site-packages (0.11.15)
(env) anubia#my-server:/opt/odoo$ cd env/lib/python3.8/site-packages/
Display all 125 possibilities? (y or n)
Babel-2.9.1.dist-info/ attrs-21.2.0.dist-info/ docutils/ numpy-1.21.0.dist-info/ python_stdnum-1.16.dist-info/ urllib3-1.26.6.dist-info/
Crypto/ babel/ docutils-0.17.1.dist-info/ numpy.libs/ pytz/ validate_email-1.3.dist-info/
Jinja2-3.0.1.dist-info/ bcrypt/ gevent/ paramiko/ pytz-2021.1.dist-info/ vatnumber/
MarkupSafe-2.0.1.dist-info/ bcrypt-3.2.0.dist-info/ gevent-21.1.2.dist-info/ paramiko-2.7.2.dist-info/ reportlab/ vatnumber-1.2.dist-info/
OpenSSL/ cached_property-1.5.2.dist-info/ greenlet/ passlib/ reportlab-3.5.68.dist-info/ werkzeug/
PIL/ cachetools/ greenlet-1.1.0.dist-info/ passlib-1.7.4.dist-info/ reportlab.libs/ wheel/
Pillow-8.3.1.dist-info/ cachetools-4.2.2.dist-info/ html2text/ phonenumbers/ requests/ wheel-0.36.2.dist-info/
Pillow.libs/ certifi/ html2text-2020.1.16.dist-info/ phonenumbers-8.12.27.dist-info/ requests-2.25.1.dist-info/ xlrd/
PyNaCl-1.4.0.dist-info/ certifi-2021.5.30.dist-info/ idna/ pip/ requests_file-1.5.1.dist-info/ xlrd-2.0.1.dist-info/
PyPDF2/ cffi/ idna-2.10.dist-info/ pip-21.3.1.dist-info/ requests_toolbelt/ xlsxwriter/
PyPDF2-1.26.0.dist-info/ cffi-1.14.5.dist-info/ isodate/ pkg_resources/ requests_toolbelt-0.9.1.dist-info/ xlwt/
PyYAML-3.12.dist-info/ cffi.libs/ isodate-0.6.0.dist-info/ polib-1.1.1.dist-info/ sassutils/ xlwt-1.3.0.dist-info/
Unidecode-1.2.0.dist-info/ chardet/ jinja2/ psutil/ setuptools/ xmlsig/
Werkzeug-0.11.15.dist-info/ chardet-4.0.0.dist-info/ libsass-0.21.0.dist-info/ psutil-5.8.0.dist-info/ setuptools-57.1.0.dist-info/ xmlsig-0.1.5.dist-info/
XlsxWriter-1.4.4.dist-info/ cryptography/ lxml/ psycopg2/ six-1.16.0.dist-info/ yaml/
__pycache__/ cryptography-3.4.7.dist-info/ lxml-4.6.3.dist-info/ psycopg2-2.9.1.dist-info/ stdnum/ zeep/
_distutils_hack/ dateutil/ markupsafe/ pyOpenSSL-20.0.1.dist-info/ suds/ zeep-4.0.0.dist-info/
appdirs-1.4.4.dist-info/ decorator-5.0.9.dist-info/ nacl/ pycparser/ suds_jurko-0.6.dist-info/ zope/
asn1crypto/ defusedxml/ num2words/ pycparser-2.20.dist-info/ tests/ zope.event-4.5.0.dist-info/
asn1crypto-1.4.0.dist-info/ defusedxml-0.7.1.dist-info/ num2words-0.5.10.dist-info/ pycryptodome-3.10.1.dist-info/ unidecode/ zope.interface-5.4.0.dist-info/
attr/ docopt-0.6.2.dist-info/ numpy/ python_dateutil-2.8.1.dist-info/ urllib3/
So werkzeug seems to be installed. What is the problem?
EDIT
After trying with #ChesuCR answer two weeks, the Odoo server stopped working again. This time the error is:
ModuleNotFoundError: No module named 'PyPDF2'
However, if I check the virtualenv:
myuser#myserver:/opt/odoo$ . venv3.7/bin/activate
(venv3.7) myuser#myserver:/opt/odoo$ which python3.7
/opt/odoo/venv3.7/bin/python3.7
(venv3.7) myuser#myserver:/opt/odoo$ python3.7 -m pip install PyPDF2
Requirement already satisfied: PyPDF2 in ./venv3.7/lib/python3.7/site-packages (1.26.0)
(venv3.7) myuser#myserver:/opt/odoo$ python3.7 -m pip list
Package Version
----------------- ---------
appdirs 1.4.4
attrs 21.2.0
Babel 2.6.0
beautifulsoup4 4.10.0
cached-property 1.5.2
certifi 2021.10.8
cffi 1.15.0
chardet 3.0.4
cryptography 36.0.0
decorator 4.3.0
defusedxml 0.7.1
docutils 0.14
ebaysdk 2.1.5
gevent 1.5.0
greenlet 0.4.15
html2text 2018.1.9
idna 2.8
isodate 0.6.0
Jinja2 2.10.1
libsass 0.17.0
lxml 4.3.2
Mako 1.0.7
MarkupSafe 1.1.0
mock 2.0.0
num2words 0.5.6
ofxparse 0.19
passlib 1.7.1
pbr 5.8.0
Pillow 6.1.0
pip 21.3.1
polib 1.1.0
psutil 5.6.6
psycopg2 2.7.7
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pydot 1.4.1
pyOpenSSL 21.0.0
pyparsing 2.2.0
PyPDF2 1.26.0
pyserial 3.4
python-dateutil 2.7.3
python-stdnum 1.17
pytz 2019.1
pyusb 1.0.2
qrcode 6.1
reportlab 3.5.13
requests 2.21.0
requests-toolbelt 0.9.1
setuptools 57.5.0
six 1.16.0
soupsieve 2.3.1
urllib3 1.24.3
vatnumber 1.2
vobject 0.9.6.1
Werkzeug 0.14.1
wheel 0.37.0
xlrd 1.1.0
XlsxWriter 1.1.2
xlwt 1.3.0
zeep 3.2.0
And of course Odoo is running with the Python interpreter of the virtualenv:
ExecStart=/opt/odoo/venv3.7/bin/python3.7 /opt/odoo/odoo_13/src/oca/OCB/odoo-bin -c /opt/odoo/odoo_13/config/.odoo.conf
I don't know what Odoo is, but in order to find the packages, you usually need to "activate" the virtualenv. Just like you did manually, but you also need that when Odoo is running the program. It is not enough to just call the correct python binary. So you can either try to have Odoo activate the venv before it starts the program, or if not possible, emulate doing that (it's probably mostly setting PATH and PYTHONPATH environment variables)
Odoo 13 is not compatible with the Python 3.8 version. You can try with Python 3.7 or 3.6 versions. Anyway, many issues have been fixed, so I am not sure about the Python 3.8 incompatibility. But, in principle, the branch Odoo v13 was created for Python 3.6, as you can check in the setup.py file
If the problem still bothers you, try to install the exact versions that Odoo developers posted in the requirements.txt file, where dependencies should have been tested. So you can install the right Werzeug version:
pip install Werkzeug==0.14.1
Ah, and if you want to show all the installed packages you can do:
pip list
For me, I had to fix it like this:
First of all and a key point is that I had to use root user, not ubuntu not odoo nothing, only root
I activated my venv in root user
I installed required packages: pip3 install paramiko (or any other packages: boto3, or pretty-bad-protocol)
and then I could install the module from the odoo admin backend, and it's working just fine
In Ubuntu 16.04. I am trying to install cntk (package downloaded from githup- cntk for Linux version and for CPU only).
I followed the procedure written in GitHub. Step 1:
anjana#anjana-VirtualBox:~/cntk/Scripts/install/linux$ ./install-cntk.sh
I got the following error
.Could not connect to https://repo.continuum.io/pkgs/pro/noarch/
..
Solving package specifications: .
Error: Packages missing in current linux-64 channels:
- h5py 2.6.0 np111py35_2
- matplotlib 1.5.3 np111py35_0
- numpy 1.11.2 py35_0
- pandas 0.19.1 np111py35_0
- pillow 3.4.2 py35_0
- pyyaml 3.12 py35_0
- scipy 0.18.1 np111py35_0
- seaborn 0.7.1 py35_0
- setuptools 27.2.0 py35_0
+ echo Creating Anaconda environment failed.
Creating Anaconda environment failed.
+ rm -rf /home/anjana/anaconda3/envs/cntk-py35
+ exit 1
This is might be due to proxy issues during the anaconda update after install. See: http://conda.continuum.narkive.com/crmi1F8C/could-not-connect-to-http-repo-continuum-io-pkgs-pro-linux-64
I am trying to use the ECMWF GRIB_API to access GRIB files from Python. I get this error
Traceback (most recent call last):
File "/home/martin/markj/JustImportGRIB.py", line 1, in <module>
from gribapi import *
ImportError: No module named gribapi
One line of code :)
from gribapi import *
I am using Anaconda Python 2.7.12, Linux Centos 64-bit, installed as user and not added Anaconda to the path if that's relevant - the system Python (2.6) is on the path. I installed GRIB_API from the Pingu Carsti channel which was the top Google hit. The conda install did not report any errors.
[martin#bonnie ~]$ anaconda2/bin/conda install -c pingucarsti grib_api=1.10.4
Fetching package metadata .........
Solving package specifications: ..........
Package plan for installation in environment /home/martin/anaconda2:
The following packages will be downloaded:
package | build
---------------------------|-----------------
grib_api-1.10.4 | 3 1.7 MB pingucarsti
The following NEW packages will be INSTALLED:
grib_api: 1.10.4-3 pingucarsti
Proceed ([y]/n)? y
Fetching packages ...
grib_api-1.10. 100% |################################| Time: 0:00:01 1.24 MB/s
Extracting packages ...
[ COMPLETE ]|###################################################| 100%
Linking packages ...
[ COMPLETE ]|###################################################| 100%
I found some bug reports about this error being caused by a bug in the ECMWF GRIB_API, but I don't know enough about Anaconda (or perhaps Python) to figure out how to apply the workarounds.
I read GRIB files in Python with pygrib. I have successfully installed it inside a conda virtual environment (Miniconda2 on Ubuntu 16.04). Here is what has worked for me:
Install system dependencies for pygrib:
sudo apt-get install libjpeg9
sudo apt-get install libgrib-api-dev
Install pygrib and ecmwf_grib from conda-forge channel.
conda install -c conda-forge pygrib ecmwf_grib
Try conda-forge's build at python-eccodes (note: that's not eccodes which is the C library).
How it is built: https://github.com/conda-forge/python-eccodes-feedstock/blob/master/recipe/meta.yaml
The ECMWF's ecCodes library is the next version of their GRIB API, and is extremely similar to the old GRIB API.
pelson> conda create -n gribby -c conda-forge python-eccodes
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment /Users/pelson/miniconda/envs/gribby:
The following NEW packages will be INSTALLED:
ca-certificates: 2017.7.27.1-0 conda-forge
curl: 7.54.1-0 conda-forge
eccodes: 2.4.0-0 conda-forge
hdf4: 4.2.12-0 conda-forge
hdf5: 1.8.18-1 conda-forge
intel-openmp: 2018.0.0-h68bdfb3_7 defaults
jasper: 1.900.1-4 conda-forge
jpeg: 9b-1 conda-forge
krb5: 1.14.2-0 conda-forge
libgfortran: 3.0.1-h93005f0_2 defaults
libnetcdf: 4.4.1.1-8 conda-forge
libpng: 1.6.28-1 conda-forge
libssh2: 1.8.0-1 conda-forge
mkl: 2018.0.0-h5ef208c_6 defaults
ncurses: 5.9-10 conda-forge
numpy: 1.13.3-py27h62f9060_0 defaults
openssl: 1.0.2l-0 conda-forge
python: 2.7.14-0 conda-forge
python-eccodes: 2.4.0-py27_1 conda-forge
readline: 6.2-0 conda-forge
sqlite: 3.13.0-1 conda-forge
tk: 8.5.19-2 conda-forge
zlib: 1.2.8-3 conda-forge
#
# To activate this environment, use:
# > source activate gribby
#
# To deactivate an active environment, use:
# > source deactivate
#
pelson> source activate gribby
python(gribby) pelson> python
Python 2.7.14 | packaged by conda-forge | (default, Oct 5 2017, 23:08:53)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gribapi
>>> gribapi.__version__
'2.4.0'
I created a new environment with
conda create -n scraping python=2.7
I activate this environment with
source activate scraping
Then I proceed to install scrapy with (-n scraping doesn't seem necessary anymore, but I added it just in case)
conda install scrapy -n scraping
I now have the following installed
% conda list
# packages in environment at /Users/alexis/anaconda3/envs/scraping:
#
cffi 1.1.2 py27_0
cryptography 0.9.2 py27_0
cssselect 0.9.1 py27_0
enum34 1.0.4 py27_0
idna 2.0 py27_0
ipaddress 1.0.7 py27_0
ipython 3.2.1 py27_0
libxml2 2.9.2 0
libxslt 1.1.28 2
lxml 3.4.4 py27_0
nose 1.3.7 py27_0
openssl 1.0.1k 1
pip 7.1.0 py27_0
pyasn1 0.1.7 py27_0
pycparser 2.14 py27_0
pyopenssl 0.14 py27_0
python 2.7.10 0
python.app 1.2 py27_4
queuelib 1.2.2 py27_0
readline 6.2 2
scrapy 0.24.4 py27_0
setuptools 18.0.1 py27_0
six 1.9.0 py27_0
sqlite 3.8.4.1 1
tk 8.5.18 0
twisted 15.2.1 py27_0
w3lib 1.8.1 py27_1
zlib 1.2.8 0
zope.interface 4.1.2 py27_1
(I also installed ipython)
Now when I try to start a project I get
% scrapy startproject megadeluxe
Traceback (most recent call last):
File "/Users/alexis/anaconda3/envs/scraping/bin/scrapy", line 4, in <module>
from scrapy.cmdline import execute
File "/Users/alexis/anaconda3/envs/scraping/lib/python2.7/site- packages/scrapy/__init__.py", line 48, in <module>
from scrapy.spiders import Spider
ImportError: No module named spiders
Looking at the content of scraping/bin/scrapy I see no file named spiders.py and if I grep for class Spider I get no such class anywhere.
Did I do something wrong with the conda install at first? I install python 2.7, which is the requirement.
which openssl returns (I think that it's fine)
/Users/alexis/anaconda3/envs/scraping/bin/openssl
lxml is installed as we can see from conda list
I'm a little clueless here.
[Edit]
As mentioned in the comments, I was not using the latest version of scrap. This does not explain the error, but I proceeded to install the latest version (1.0) with pip (as of this writing conda only install version 0.24).
After doing so, starting a project would spit something out, ending with Library not loaded: libssl.1.0.0.dylib
Looking this up on stack overflow returned me this link
Cannot Set Up a Scrapy Project
The answer given by Joe Hooper solved my problem
https://stackoverflow.com/a/26961576/2883980
After all this I now have a solution, but have no clue as to the root reason.
I will put this here so other may find this useful (because I had no idea what DYLD_LIBRARY_PATH was used for)
man dyld
DESCRIPTION
The dynamic linker uses the following environment variables.
They affect any program that uses the dynamic linker.
DYLD_FRAMEWORK_PATH
This is a colon separated list of directories that contain
frameworks. The dynamic linker searches these
directories before it searches for the framework by its
install name. It allows you to test new versions of
existing frameworks. (A framework is a library install
name that ends in the form XXX.framework/Versions/YYY/XXX
or XXX.framework/XXX, where XXX and YYY are any name.)
For each framework that a program uses, the dynamic linker
looks for the framework in each directory in
DYLD_FRAMEWORK_PATH in turn. If it looks in all the
directories and can't find the framework, it searches the
directories in DYLD_LIBRARY_PATH in turn. If it still
can't find the framework, it then searches
DYLD_FALLBACK_FRAMEWORK_PATH and DYLD_FALL-
BACK_LIBRARY_PATH in turn.
Use the -L option to otool(1). to discover the frameworks
and shared libraries that the executable is linked
against.
I noticed that you have the scrapy version 0.24.4 installed. Any reasons you're not running the new version 1.0 ?
I believe Scrapy.spiders is a 1.0 class, and not a 0.24 one. I would try to get the really last version installed in your environment, and see if this works.
I was working on exactly the same task as you do.
I followed the steps in here to create an environment:
Create the environment
And here to activate my environment:
Activate the newly created environment
I was working these out with anaconda command prompt.
I installed Scrapy a long time ago and therefore when I create the environment, scrapy is already there.
Currently I am having problems with importing items.py :
My question
Let me know if I could help further.