Weird symbols while trying to install a package in PyCharm project - python

The error appears when I try to install any package with command: "poetry add " or manually "File -> Settings -> Project -> + in the corner -> search package -> press "install" button"
I have the project named "example-ed-tech" in university and poetry base interpreter of version 3.10.5
I've tried terminal commands and manual installation.
Probably, there's some problem with encoding?
Traceback:
traceback: "‘Ёб⥬Ґ ­Ґ г¤ Ґвбп ­ ©вЁ гЄ § ­­л© Їгвм. Command C:\Users\xc8\xe3\xee\xf0\xfc.pyenv\pyenv-win\versions\3.10.5\python.exe -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 1, and output:"
Error screenshot

Related

Python xlwings fails to run COM server

I’m a stumped. Xlwings is reporting failure to activate the COM server. I am using Excel 365 on Windows 10 and xlwings 0.17.1 (Excel module version 0.20.5) and using a python 3.8 conda environment crated directly through Anaconda Navigator.
In Excel, I traced the error to a shell command (below), which is kicked off by Excel XLPyCommand() in the xlwings Module (xlwings quickstart myproject --standalone).
cmd.exe /K ""C:\Users\Chris\anaconda3\condabin\conda" activate xw_cja && pythonw -B -c "import sys, os;sys.path[0:0]=os.path.normcase(os.path.expandvars(r'D:\Code\Python\AnacondaVenvs\xw_cja;D:\Code\Python\AnacondaVenvs\xw_cja\advena_xw.zip;C:\Users\Chris\anaconda3\envs\xw_cja')).split(';');import xlwings.server; xlwings.server.serve('$(CLSID)')"
I created a simple .py file to run this in PyCharm directly. I replaced “('$(CLSID)')” with “(‘{506e67c3-55b5-48c3-a035-eed5deea7d6d}’)”, which is hard-coded by the developer in both the Excel VBA and the python code.
import sys, os
os.path.expandvars(r'D:\Code\Python\AnacondaVenvs\xw_cja;D:\Code\Python\AnacondaVenvs\xw_cja\advena_xw.zip;C:\Users\Chris\anaconda3\envs\xw_cja')
sys.path[0:0]=os.path.normcase(os.path.expandvars(r'D:\Code\Python\AnacondaVenvs\xw_cja;D:\Code\Python\AnacondaVenvs\xw_cja\advena_xw.zip;C:\Users\Chris\anaconda3\envs\xw_cja')).split(';')
import xlwings.server
xlwings.server.serve('{506e67c3-55b5-48c3-a035-eed5deea7d6d}')
The code above runs just fine in a standalone ‘.py’ file (in PyCharm).
FYI: I used MKLINK -j (in a batch file) to make a directory junction link C:\Users\Chris\anaconda3\envs to D:\Code\Python\AnacondaVenvs, which makes them synonyms. This is unrelated, but wihtout this knowledge, you may mistakenly observe path discrepancies in the code above. (As an aside, I do this to make data on my D drive appear to be on C to manage the space on C)
The shell opened, showing the command is run against the correct conda environment, xw_cja.
Excel hourglassed for at least a minute. Then, I got this error: "Could not activate Python COM server, hr = -2147221164 1000"
I opened a command prompt and ran the following with no errors.
C:\Users\Chris>"C:\Users\Chris\anaconda3\condabin\conda" activate xw_cja
(xw_cja) C:\Users\Chris>pythonw -B -c "import sys, os;sys.path[0:0]=os.path.normcase(os.path.expandvars(r'D:\Code\Python\AnacondaVenvs\xw_cja;D:\Code\Python\AnacondaVenvs\xw_cja\advena_xw.zip;C:\Users\Chris\anaconda3\envs\xw_cja\')).split(';')
(xw_cja) C:\Users\Chris>pythonw -B -c "import xlwings.server"
(xw_cja) C:\Users\Chris>pythonw -B -c "import xlwings.server.serve('$(CLSID)')"
(xw_cja) C:\Users\Chris>pythonw -B -c "import sys, os;sys.path[0:0]=os.path.normcase(os.path.expandvars(r'D:\Code\Python\AnacondaVenvs\xw_cja;D:\Code\Python\AnacondaVenvs\xw_cja\advena_xw.zip;C:\Users\Chris\anaconda3\envs\xw_cja\')).split(';');import xlwings.server; xlwings.server.serve('$(CLSID)')"
(xw_cja) C:\Users\Chris>
I opened a new command prompt / shell and tried the full command as a single line with no error reported.
C:\Users\Chris>"C:\Users\Chris\anaconda3\condabin\conda" activate xw_cja && pythonw -B -c "import sys, os;sys.path[0:0]=os.path.normcase(os.path.expandvars(r'D:\Code\Python\AnacondaVenvs\xw_cja;D:\Code\Python\AnacondaVenvs\xw_cja\advena_xw.zip;C:\Users\Chris\anaconda3\envs\xw_cja\')).split(';');import xlwings.server; xlwings.server.serve()
(xw_cja) C:\Users\Chris>
Here is my config data as set on the 'xlwings.conf' worksheet (yes, I removed the leading underscore).
Interpreter_Win pythonw
PYTHONPATH C:\Users\Chris\anaconda3\envs\xw_cja\
Conda Path C:\Users\Chris\anaconda3
Conda Env xw_cja
UDF Modules advena_xw;udf
Debug UDFs FALSE
Log File
Use UDF Server FALSE
Show Console FALSE
So, this was very interesting. I was using a conda environment. Even so, adding the anaconda path variables to my system environment variables (Windows 10) resolved the issue. it is my understanding from the xlwings documentation that this is not needed. But it resolved my problem. I did verify that, for most python scripts triggered from Excel, xlwings is using the conda environment. However, I must have the same version of xlwings dll files in both the conda environment and the main python installation. I have not had this problem when using venv in the past (the native python virtual environment library).

problem with Run python3 code in Atom on ubuntu

script i am using this package on atom.
getting this error
[Command: python3 -u '/home/aditya/Documents/python/py4e book solved problems/not done py4e 5.10ex q1 loop.py']
after making change to. [/home/aditya/.atom/packages/script/lib/grammars] i had changed python to python3
exports.Python =
'Selection Based':
command: 'python3'
args: (context) -> ['-u', '-c', context.getCode()]
'File Based':
command: 'python3'
args: ({filepath}) -> ['-u', filepath]
EDIT: if you just want to run python3 through atom:
Open the atom-python-run package settings (atom Settings >> packages >> find atom-python-run >> settings)
In F5 command section, change the default to python3 {file}. It should look something like this.
EDIT: Make sure that F5 doesn't interfere with another command from another package. Or else you can use F6 as well.
Restart, atom. You should be good to go!
If you aren't able to run python scripts through atom. Then here's the package you can install.
atom-python-run
In short:
You need python installed on your computer and you need to add it to your PATH
Restart atom
To run your (.py) file, hit F5 or F6
Hope this helps!
Try running "sudo ln -s /usr/bin/python3 /usr/bin/python".
Anyway you can change the default to python3 {file} on settings atom python run from.

JupyterLab build is suggested and successfully installed, but will not work. Why?

I'm running JupyterLab from Anaconda, and installed a JupyterLab plotly extension using:
conda install -c conda-forge jupyterlab-plotly-extension
Apparently, the installation was successful, but something is still wrong.
When launching JuyterLab, I'm getting this prompt:
Clicking BUILD gives me this:
And clicking RELOAD relods JupyterLab, BUT I'm getting this again:
And on and on it spins. Does anyone know why?
Clicking CANCEL does not help either because plotly won't produce any plots, only blank spaces:
Solution:
Deactivate firewall and run the following command in a windows command prompt:
jupyter lab build
The details:
This turned out to be a firewall problem, and I'm not sure why it would not be prompted as such in the JupyterLab interface. The following command in a windows command prompt returned the error message below:
Command:
jupyter lab build
Output:
C:>jupyter labextension list JupyterLab v0.34.9 Known labextensions:
app dir:
C:\Users*******\AppData\Local\Continuum\anaconda3\share\jupyter\lab
#jupyterlab/plotly-extension v0.18.2 enabled ok
Build recommended, please run jupyter lab build:
#jupyterlab/plotly-extension needs to be included in build
C:>jupyter lab build [LabBuildApp] JupyterLab 0.34.9 [LabBuildApp]
Building in
C:\Users*******\AppData\Local\Continuum\anaconda3\share\jupyter\lab
[LabBuildApp] > node
C:\Users*******\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js
install yarn install v1.9.4 info No lockfile found. [1/4] Resolving
packages... error An unexpected error occurred:
"https://registry.yarnpkg.com/#jupyterlab%2fapplication: self signed
certificate in certificate chain". info If you think this is a bug,
please open a bug report with the information provided in
"C:\Users\*******\AppData\Local\Continuum\anaconda3\share\jupyter\lab\staging\yarn-error.log".
What pointed me towards suspecting a firewall problem was this part:
self signed certificate in certificate chain
Running the same command on less rigid fire-wall settings triggers this output (shortened):
WARNING in d3-array Multiple versions of d3-array found:
1.2.4 ./~/d3-scale/~/d3-array from ./~/d3-scale/~/d3-array\src\index.js
2.2.0 ./~/d3-array from ./~/d3-array\src\index.js
Check how you can resolve duplicate packages:
https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin#resolving-duplicate-packages-in-your-bundle
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[KTNU] ./node_modules/html-loader!./templates/partial.html 567 bytes {0} [built]
[YuTi] (webpack)/buildin/module.js 497 bytes {0} [built]
[aS2v] ./node_modules/html-webpack-plugin/lib/loader.js!./templates/template.html
1.22 KiB {0} [built]
[yLpj] (webpack)/buildin/global.js 489 bytes {0} [built]
+ 1 hidden module
And despite some warning messages, JupyterLab now produces plotly figures without any problems:

Can not find the directory which is installing

In my Mac, I use sudo easy_install the Django:
aircraftdeMacBook-Pro:~ ldl$ sudo easy_install django
Password:
Searching for django
Reading https://pypi.python.org/simple/django/
Best match: Django 1.11.2
Downloading https://pypi.python.org/packages/c0/31/4bffd9183066eea645430114419c30b030b599320da8246701b81c6a78d2/Django-1.11.2.tar.gz#md5=f089f1f86d25f2b78f6cf36478d4edd1
Maybe the Django is large to install, but I stuck in there too much time, so I want to use su -du Django_directory to look if it is installing.
But I use whereis django, I get nothing:
aircraftdeMacBook-Pro:~ ldl$ whereis Django
aircraftdeMacBook-Pro:~ ldl$
How can I find it in my Mac?
I use the locate -b djnago, get the below information:
aircraftdeMacBook-Pro:site-packages ldl$ locate -b djnago
locate: illegal option -- b
usage: locate [-0Scims] [-l limit] [-d database] pattern ...
default database: `/var/db/locate.database' or $LOCATE_PATH
Ok so you go into the Finder -> Macintosh HD -> Library -> Python -> 2.x/3.x -> site-packages -> Django
If you can't see it try to show the hidden folders (cmd + shift + . )
I hope that is what you are looking for
p.s. what you can do and is working for me:
open terminal 1. ./manage.py shell -> 2. import django -> 3 django and the terminal will show you the path as well

invalid Syntax rm -rf temp (Cygwin)

Shell/OS: Cygwin/Windows 7
Source code: Source code
Required package: Required package
Installation:
I downloaded the following Source code on windows. I moved the requited package to models and I installed the package by using the following command: python setup.py install
Test:
by using Cygwin I wanted to test the package by typing: ./run-test:
#!/cygdrive/c/Python27/python
rm -rf temp
ocropus-nlbin tests/testpage.png -o temp
ocropus-gpageseg 'temp/????.bin.png'
ocropus-rpred -n 'temp/????/??????.bin.png'
ocropus-hocr 'temp/????.bin.png' -o temp.html
ocropus-visualize-results temp
ocropus-gtedit html temp/????/??????.bin.png -o temp-correction.html
echo "to see recognition results, type: firefox temp.html"
echo "to see correction page, type: firefox temp-correction.html"
echo "to see details on the recognition process, type: firefox temp/index.html"
Error:
File "./run-test", line 3
rm -rf temp
^
SyntaxError: invalid syntax
What caused this error?
The #! line says this is a Python script. So why would a shell command be acceptable syntactically?
Try #!/bin/sh/ instead.

Categories

Resources